This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Servlets and the fly likes Request needs to be POST In servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Request needs to be POST In servlet" Watch "Request needs to be POST In servlet" New topic
Author

Request needs to be POST In servlet

Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
I have a requirement that from the jsp, when they click on the link. I will call the servlet, in this i need to add a new parameters with the url and send it as the POST request.

The destination URL is a new domain. Could you please help me on how to send the request as POST method in servlet with the add new parameters.


Nalini Nagarathinam
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

In a POST the parameters should be passed in the request body, not on the URL. That's how parameters are passed on GETs.

So your requirements are rather screwy.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nalini Nagarathinam
Greenhorn

Joined: Jun 13, 2010
Posts: 16
Thanks for your reply..

How to add the parameters in the request body and send it as the POST request?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61106
    
  66

To send it to another web application in another domain?

You could either use a tool such as HttpClient to create the request, or you could dynamically create a JSP form and cuase it to be posted with some JavaScript.

The former would be the more elegant and versatile approach.
 
Consider Paul's rocket mass heater.
 
subject: Request needs to be POST In servlet