aspose file tools*
The moose likes Struts and the fly likes how to capture form varibales in JSP and form a html link? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "how to capture form varibales in JSP and form a html link?" Watch "how to capture form varibales in JSP and form a html link?" New topic
Author

how to capture form varibales in JSP and form a html link?

rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Hi,
I have two drop down lists. Once a user selects once
item for every list, she will press on submit button.
The two lists are collections. I am trying to capture
these two values after the user submission. Can I set my
action form in session scope in action class, then get
form varaibales as strings in my jsp page?
Another question is: I will append these strings at the
end of a html link, and add to an taglib element's url parameter.
I am wondering how to do that in jsp page?
For example:
if 2 strings got from form are:
String id="111";
String ssn="333";
<mytag:table name="persons" uri="http://myweb.com/mypage?companyid="+id+"&ssn="+ssn>
In Java, we can concatenate strings like that, in Jsp, can we do that?
Or there is another way?
regards,
rick
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi,
first of all a JSP is simply a Servlet. It is not good practice but you can also write Scriptlets here, just put them between <% %> and the compiler will create the code in the servlet.
I wouldn't put your Form to Session if not really necessary. It you simply need it in the next step, you can store it as an attribute in the request amd simply get it out there. The main disadvantage is that when stored in the session the object exists on the heap the complete session time. So you should try to have as few objects in session as possible.
I didn't get it if the Collection is hold in your form class or directly in the request. But you can get it with on the JSP:

when the collection is directly stored in the request

[ August 05, 2003: Message edited by: Oliver Refle ]
rick collette
Ranch Hand

Joined: Mar 22, 2002
Posts: 208
Thanks, Oliver:
So, my action form must be in the classpath to be imported in my Jsp file?
Sounds messy, but I will try it out if it works.
regards,

Originally posted by Oliver Refle:
Hi,
first of all a JSP is simply a Servlet. It is not good practice but you can also write Scriptlets here, just put them between <% %> and the compiler will create the code in the servlet.
I wouldn't put your Form to Session if not really necessary. It you simply need it in the next step, you can store it as an attribute in the request amd simply get it out there. The main disadvantage is that when stored in the request the object exists on the heap the complete session time. So you should try to have as few objects in session as possible.
I didn't get it if the Collection is hold in your form class or directly in the request. But you can get it with on the JSP:

when the collection is directly stored in the request
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to capture form varibales in JSP and form a html link?