aspose file tools*
The moose likes Servlets and the fly likes Call servlet from servlet passing request parameters Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Call servlet from servlet passing request parameters" Watch "Call servlet from servlet passing request parameters" New topic
Author

Call servlet from servlet passing request parameters

Praveen Kumar Anekalmath
Greenhorn

Joined: Feb 26, 2007
Posts: 18
Hi,

I need to call a third party servlet from my application servlet and pass request parameters. I can use URLConnection and perform doPost. But here I cannot pass request parameters. Please suggest.

Praveen


Praveen
Saifuddin Merchant
Ranch Hand

Joined: Feb 08, 2009
Posts: 606

Praveen Kumar Anekalmath wrote:Hi,

I need to call a third party servlet from my application servlet and pass request parameters. I can use URLConnection and perform doPost. But here I cannot pass request parameters. Please suggest.

Praveen


Why not? Here is an example that might help -- http://java.sun.com/docs/books/tutorial/networking/urls/readingWriting.html



Cheers - Sam.
Twisters - The new age Java Quiz || My Blog
Praveen Kumar Anekalmath
Greenhorn

Joined: Feb 26, 2007
Posts: 18
Hi Sam

By following URLConnection method, I can read the request line by line that is taking as input stream. But I need to read as parameter by parameter. Any suggestions?

Praveen
Praveen Kumar Anekalmath
Greenhorn

Joined: Feb 26, 2007
Posts: 18
Hi Sam,

I mean to say, I am setting request parameter as request.setAttribute("abc", "test123"); in calling servlet.
The same has to be read in called servlet.

Praveen
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42264
    
  64
I am setting request parameter as request.setAttribute("abc", "test123"); in calling servlet.
The same has to be read in called servlet.

That's not possible. Request attributes are a concept that's internal to a servlet engine - they're not part of an HTTP call that you make to some other URL. You'll need to use HTTP parameters instead. Using a library like Apache HttpClient for this is easier than using URLConnection directly.


Ping & DNS - my free Android networking tools app
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Call servlet from servlet passing request parameters