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 How to redirect to a JSP(with different param values) with  POST method? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » JSP
Reply Bookmark "How to redirect to a JSP(with different param values) with  POST method?" Watch "How to redirect to a JSP(with different param values) with  POST method?" New topic
Author

How to redirect to a JSP(with different param values) with POST method?

Chandima Panditha
Greenhorn

Joined: Jan 21, 2003
Posts: 1
Hi,
I need to call a JSP page with different values (in a loop where CustID=1, CustID=2, etc) with the "POST" method. I need to do what's below html code (first 3 lines) is doing using JSP. The reason why I need to to in a JSP (or Servlet or an Applet) is, I need to loop through few CustIDs, for ex CustID=1, CustID=2, etc.
Any help is really appreciated...
Thanks
Chandi


customer.html
<form name="cust_details"
action="http://localhost:8080/customer/displayItems.jsp?CustID=1"
method="post">

<table border="0">
<tr>
<td><div align="right"> Email : </div></td>
<td ><input name="username" type="text" > </td>
</tr>
<tr>
<td><div align="right"> Password: </div></td>
<td><input name="password" type="password" ></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input name="Submit" type="submit" value="Login">
</div></td>
</tr>
</table>
Marty Hall
Author
Ranch Hand

Joined: Jan 02, 2003
Posts: 111
I need to call a JSP page with different values (in a loop where CustID=1, CustID=2, etc) with the "POST" method. I need to do what's below html code (first 3 lines) (ie a FORM with METHOD=POST) is doing using JSP.

Hmm. Do you need to see the output of the JSP? Or just invoke the URL (where, presumably, the JSP performs some side effect that you want)?
If the latter, this can be done using a URLConnection with setDoOutput(true) and a Writer or OutputStream to send the data. Don't forget to use URLEncoder.encode on the data before you send it. Of course you would do this from a servlet or regular application, not a JSP, though.
I have an example that walks you through this in Section 17.5 of Core Servlets and JavaServer Pages, which is online in PDF for free access at http://pdf.coreservlets.com/. That example is in the context of an applet invoking a URL, but the code is the same for any Java program.
Cheers-
- Marty


Java training and consulting<br /><a href="http://www.coreservlets.com/" target="_blank" rel="nofollow">http://www.coreservlets.com/</a>
 
IntelliJ Java IDE
 
subject: How to redirect to a JSP(with different param values) with POST method?
 
Threads others viewed
URLConnection and form based authentication
Struts IE render problem
Help me about html:select
how show values in jsp from getting database
problem in jsp !!!
IntelliJ Java IDE