Win a copy of Murach's Java Programming this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

HTTPUrlConnection  RSS feed

 
mi go
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to use HTTPUrlConnetion class to communicate bewtween two servlets like passing the data from one servlet through GET or POST method and have it returned from second servlet. Both servlets are in different web projects! Can someone post the code ?

i have created following code:

WebApp1 have input.jsp as follwos:

and Account servlet

WebApp2 have billing servlet that basically capitalises string and print it:

When i run http://localhost:8080/WebApp1/input.jsp ; and send a string(e.g. fdfd) via test box and enters submit button
this url is hit http://localhost:8080/WebApp1/Account?t1=fdfd but it did not capitalise the string and fileNotFoundException comes.

can someone help me? whats wrong
 
Rob Spoor
Sheriff
Posts: 21019
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're sending a GET but with a body. That's not allowed in HTTP. You should instead just add the value as a query parameter to the URL you're trying to open.

PS: you didn't use the code tags correctly. They should go around the code block, not be placed in front of it; please re-read https://coderanch.com/wiki/659781/Code-Tags.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!