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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "form and jsp" Watch "form and jsp" New topic

form and jsp

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

I am trying to find a way to call a servlet from 2 diffrent searches in my site using only 1 form.Is that possible??
In specific i have a bookstore and i also have 2 kind of searches,one advanced with title and author,and one by category.How can i call a servlet(search) with using only one that possible...
thnx in advance...
Travis Hein
Ranch Hand

Joined: Jun 06, 2006
Posts: 161
so you have two different html input forms , one with title and author, and the second with category and you want them to be able to use the same servlet to do searching.

A hidden input field inside the forms could be used to tell the search Servlet which input form was used to invoke the servlet, and then the servlet would inspect the request parameters for the this hidden property to know what input fields to expect and how to run the search.

for example,

Error: Keyboard not attached. Press F1 to continue.
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

thnx it was that simple..i was trying way wrong.i thought i couldn't have 2 forms with the same name in the same jsp page..
thnx again..
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

Actually you should give them different names, but set the same action.

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: form and jsp
It's not a secret anymore!