Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array lists syntax in jsp

 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Ranchers i am a new bie in jsp can any body tell me how to declare an input type hidden variable of type arraylist in a form in a jsp page.
I am developing a calender in that calendar i want to store days in a month using array list and i want to pass this values to servlet
nd also tell me how to retrive the arraylist values in servlet to send this arraylist values to servlet i am using usebean tag in my jsp.

Thanks and Regards.
 
Swastik Dey
Rancher
Posts: 1603
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
input type hidden variable of type arraylist


input type hidden has got something to do with html and ArrayList is a java class, what is the relationship between these two?
 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply it's a mistake not hidde type its a javaclass only.please reply me how to send those array list values syntax
Thanks in advance
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vina,
Still your question is confusing. Is your ArrayList is in JSP?? And you want to send that to the Servlet??

If that is the case, you can not send that ArrayList object to servlet in normal way. Because, once the jsp file is generated and sends to the browser, the server will not have access to the Java objects available in jsp. What you can do is keep the value in a session variable and update it as required.

Regards,
Y. Keerthi Sagar.
 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks foe your response i am not trying for javascript i want it in java class only
This is my jsp code and below is my javabean file
now my problem is with dispDay field actually it gives dates of current month but it is giving only one value so for the dateDisp i want to set array list please suggest me to solve this problem
Thanks in advance.
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
vina kum wrote:
//ArrayList disp= new ArrayList();


Uncomment this block and comment the following line

vina kum wrote:
String disp = "";


Now, instead of assigning the value in "dispDay" to "disp" like;

vina kum wrote:
disp = Integer.toString(dispDay);


Add the value in "dispDay" to "disp" ArrayList object like;
disp.add(Integer.toString(dispDay));

Now, in the Barchart class, change the type for the variable, "disp", from "String" to "ArrayList";

vina kum wrote:
public class Barchart implements DatasetProducer, Serializable {
public Barchart() {}
private String disp ;

public String getDisp() {
System.out.println("getDisp");
return disp;
}

public void setDisp(String disp) {
System.out.println("setDisp");
this.disp = disp;

}


Now, check with the modifications, and let me know if any problems occured.

Regards,
Y. Keerthi Sagar.
 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
Thanks for your suggestion but it's not getting it is taking only '1' for whole month i.e., not incrementing date value any suggestions please.
Thanks in advance
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vina,
I just given some broad idea, and it is a bit difficult to identify without knowing the declaration details of the variables "c", "cal" and the method details of isDate(). I don't know whether you are using any exisiting utility or it is a custom method. If isDate() is a custom method, please provide the details of that.

Regards,
Y. Keerthi Sagar.
 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sagar thanks for your reply i am dgiving the output of my code please see and verify how to increment the date value
In this code first four values are '1' dispDay value,'670','6' use bean value, and the last [1] is the array list value i am getting and the rest are getting by using for loop so here the problem is arraylist value is not incrementing. Any suggestions please
Thanks in advance.
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vina,
Can you place the complete code again, including the Bean class and the declaration details of the variables "c", "cal" and the method details of isDate(). ?

I sent you a private message with my GTalk ID. Check it and ping me. I hope it would be easier to discuss.

Regards,
Y. Keerthi Sagar.
 
vina kum
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
sagar thanks for your replies i have sented you a private message of my complete code I hope you will get the solution.
Thanks in advance
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your private messages
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64633
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please read this.
 
Keerthi Sagar
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Vina,
Put the <jsp:useBean> tag out side the forloop like;
====
<jsp:useBean id="barChart" class="com.cewolf.Barchart">
<% for (int d = 1; d < 8; d++)
====
And also put the closing tag </jsp:useBean> out side the forloop

Regards,
Y. Keerthi Sagar.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic