• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to handle doGet or doPost in JSP

 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
As in servlets we have doGet and doPost to cater to get& post requests .
In JSP's how can we have a separate behavior for a get request and a post request

Rgrds
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look at the HttpServletRequest getMethod() call to determine if GET or POST was used.
Bill
 
manish ahuja
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi William
Thanks for the reply.
This will help me in determining whether the request is get or post.
Now like in servlets how can i have separate doGet & doPost methods to be invoked on get & post requests simultaneously
Rgrds
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You shouldn't.
Use the doXXX() in the Servlet and then forward to the JSP to provide presentation.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manish,
In fact, I wonder why you need to have such a separation in JSP.
Anyway, you may do the following manually:

However, unlike Servlets, I think this may not really need.
Nick.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!