Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within HTML Pages with CSS and JavaScript
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
paul wheaton
Liutauras Vilda
Ron McLeod
Sheriffs:
Jeanne Boyarsky
Devaka Cooray
Paul Clapham
Saloon Keepers:
Scott Selikoff
Tim Holloway
Piet Souris
Mikalai Zaikin
Frits Walraven
Bartenders:
Stephan van Hulst
Carey Brown
Forum:
HTML Pages with CSS and JavaScript
form submit
santosh garg
Greenhorn
Posts: 10
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Dear all,
I have two buttons in my form and I want to form to be submitted and redirected to different
JSP
pages for each buttons, i.e; if I press search button it should redirect to search.jsp and if press update it should redirect to update.jsp.
Thank you
harilal ithikkat
Ranch Hand
Posts: 221
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
<script language="javascript"> function action1() { document.form.action="first.jsp"; document.form.method="post"; document.form.submit(); } function action2() { document.form.action="second.jsp"; document.form.method="post"; document.form.submit(); } </script> <html> <body> <form name="form"> <input type="button" value="first" onclick="action1()"> <input type="button" value="second" onclick="action2()"> </form> </body> </html>
SCJP 1.5
"A candle looses nothing by lighting another candle"
itechmentors.com
Bauke Scholtz
Ranch Hand
Posts: 2458
posted 15 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Use a
servlet
as page controller.
JSP
<form action="myServlet" method="post"> <input type="submit" name="search" value="search" /> <input type="submit" name="update" value="update" /> </form>
MyServlet (semi pseudo)
protected void doPost(request, response) { if (request.getParameter("search") != null) { processSearch(); request.getRequestDispatcher("search.jsp").forward(request, response); } else if (request.getParameter("update") != null) { processUpdate(); request.getRequestDispatcher("update.jsp").forward(request, response); } }
There are MVC frameworks out which simplifies this such as
Struts
and
JSF
.
She said she got a brazillian. I think owning people is wrong. That is how I learned ... tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
JSP
Please help me regarding the forms selection
Two submit buttons in a form?
how connect with database using hyper link
can i use two submit button
More...