Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending a Collection from JSP to Servlet

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

Can i send this to a servlet ??

 
jack wenttohill
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Then in servlet use


And please study the scope of jsp/servlet you will better understand more.
 
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 not possible . Is this possible with getParameter()??
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Can i send this to a servlet ??


yes you can , but shouldn't. What you achieve by calling servlet from JSP. ( it should be other way around)
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "send"? A JSP generates HTML which is then sent to the browser. Where does a servlet enter the picture?
 
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 , i thought tha question is clear :


The question is :

JSP is submitting form data :



<form method="post" action="/MySevlet">
<input type=hidden name="name" value="al"/>

</form>
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now it's clear. You can't use Java objects in HTML forms; you'll need to add all list items individually as hidden form fields.
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Thank you ulf ,

I just wanted to try but this is not even compiling "


Then how to send a java array to servlet from jsp ?
 
Ulf Dittmer
Rancher
Posts: 42968
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By doing what I suggested before.

Check the javadocs of HttpServletRequest for the reason why you're getting a compiler error.
 
Mohamed Inayath
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes it will give compilation error.
To be precise a Class Cast Exception.

getParameter() api returns String and you are trying to cast with ArrayList.

Regarding to the question, one cannot pass the Array object as part of input as it will take only Strings
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you ulf and Mohamed for the explanations .

Please tell me


How can i send this Array to a Servlet .
 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can comma separate array and send it to servlet using AJAX..
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Other than that is there any other way ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic