Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing an Array from JSP to Servlet  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator




This is all under the User Interface (the Form data) made of JSP
Please tell me how can i pass the stArray to the servlet on to server side.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that array is in the JSP, and does not go to the client. It stays on the server. So, are you trying to send data from the client's web browser to the servlet running on the server, or are you trying to pass from a JSP to a servlet, all during a single request invocation. This is an important distinction.

However, if you want to pass data between web components like Servlets and JSPs, all during a common request-response cycle, you can stuff objects into the HttpSevletRequest scope using request.setAttribute and get it using request.getAttribute. But perhaps a bit of clarification of what you're trying to do might help us help you.

-Cameron McKenzie

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry for the confusion .

Please tell me on this context "trying to send data from the client's web browser to the servlet running on the server,"

How this array is passed to the servlet


Thanks in advance.
 
karan wadhwani
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jsp is last point of request.
So if you want to send above values after again clicking on some button, then you need to store array values in
hidden field.
or set array in session, not recommended.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So if you want to send above values after again clicking on some button, then you need to store array values in hidden field.



Thanks Manish, as suggested by you , i will set this in a hidden field . But how do i retrieve array on the servlet .

Is it possible to use any other method other than getParameter () which only returns String ??

Please suggest
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTML and http is a pretty basic protocol. It just sends text over the network. Putting these values in a single comma or pipeline separated string in a hidden field, and then using a StringTokenizer or something similar in the Servlet that retrieves them, is probably the type of option you'll be looking at.

-Cameron McKenzie
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Interesting points Cameron , but i am thinking of "how to put these values in a single comma " any idea ??

Thank you.
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

You can use something like this to get array values

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"how to put these values in a single comma " any idea ??


sorry , my question is so foolish
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!