• Post Reply Bookmark Topic Watch Topic
  • New Topic

connection.setRequestMethod("POST") inside doGet()  RSS feed

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



is it okay to have POST type method in doGet() ?
 
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have seen such usage of doPost() in some projects to handle limitation of clients who are unable to communicate over doPost() directly.

But implications are the same as with doGet() in general, insecure and has limited size (256 bytes if I remember it correctly).

What are your reasons to have doPost() inside doGet()?
 
Sheriff
Posts: 21136
87
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
s ravi chandran wrote:I have seen such usage of doPost() in some projects to handle limitation of clients who are unable to communicate over doPost() directly.

But implications are the same as with doGet() in general, insecure and has limited size (256 bytes if I remember it correctly).

What are your reasons to have doPost() inside doGet()?

I think  you've misread the code. This method will perform an HTTP request to a different web application, not to the same servlet. At least I'm assuming it's a different web application, because there are easier ways to call code within the same web app.
 
mi go
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes its making call to different servlet namely WebApp1/Account who has got doPost() method. My question is that whether its normal to do or not? Or to have another servlet in WebApp1/AccountHandle that will have doGget().
 
s ravi chandran
Ranch Hand
Posts: 579
6
Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My bad, did not focus on the actual call.

Should be fine I guess.

Does HttpServletResponse  sendRedirect seem to solve your requirement? 

Here is a sample from online:

Redirect would trigger an additional call and can be used to call to other web service.
 
Author and ninkuma
Marshal
Posts: 66307
152
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mi go wrote:My question is that whether its normal to do or not?

Not very. Either redirect, forward, or factor the common code out into another class.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!