File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes jsp and forms Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp and forms" Watch "jsp and forms" New topic

jsp and forms

kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
How do I retrieve information from a form in jsp. I'm using a <select> drop box. When the user selects something from it, I want the page to recognize what was selected immediately and reload the page. Also, how do I get the page to reload immediately? I guess you could say that the page is dynamic. TIA.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
To retrieve form parameter in a JSP page use request.getParameter("param") where param is the name of the parameter.
To automatically submit a page when a item is selected in a drop-down use the onChange event of DHTML. Then use javascript to submit the form.
<form name="testForm" action="action.jsp">
<select name="testSelect" onChange="javascript:document.forms['testForm'].submit();">
<option value="1">One</option>
<option value="2">Two</option>
I didn't test it so if it doesn't work exactly... oh well.
Ryan Yeap

Joined: Apr 28, 2001
Posts: 28
Well, anyone tested? Does it work? =D

<A HREF="" TARGET=_blank rel="nofollow">An Online community for Online RPGs!</A>
kevin schmidt
Ranch Hand

Joined: Aug 24, 2001
Posts: 85
I managed to get something to work, still have a little bit of a problem though.
I agree. Here's the link:
subject: jsp and forms
It's not a secret anymore!