File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Call servlet from servlet passing request parameters

 
Praveen Kumar Anekalmath
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Saifuddin Merchant
Ranch Hand
Posts: 607
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Praveen Kumar Anekalmath
Greenhorn
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 18
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic