File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Array lists syntax in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Array lists syntax in jsp" Watch "Array lists syntax in jsp" New topic
Author

Array lists syntax in jsp

vina kum
Greenhorn

Joined: Jun 24, 2009
Posts: 21
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

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?


Swastik
vina kum
Greenhorn

Joined: Jun 24, 2009
Posts: 21
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

Joined: Apr 21, 2007
Posts: 28
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

Joined: Jun 24, 2009
Posts: 21
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

Joined: Apr 21, 2007
Posts: 28
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

Joined: Jun 24, 2009
Posts: 21
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

Joined: Apr 21, 2007
Posts: 28
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

Joined: Jun 24, 2009
Posts: 21
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

Joined: Apr 21, 2007
Posts: 28
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

Joined: Jun 24, 2009
Posts: 21
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

Joined: Apr 21, 2007
Posts: 28
Please check your private messages
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Please read this.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Keerthi Sagar
Greenhorn

Joined: Apr 21, 2007
Posts: 28
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array lists syntax in jsp