File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "form and jsp" Watch "form and jsp" New topic
Author

form and jsp

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Hello,
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 form..is 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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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


[My Blog]
All roads lead to JavaRanch
 
Don't get me started about those stupid light bulbs.
 
subject: form and jsp
 
Similar Threads
question about strut-logic .tld
Running an application bean method automatically on start?
Bean or Servlet
Invoking HTTPS webservice
Servlets JRUN