This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using Post and Get at the same time

 
Siamak Saarmann
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

1- There is a doGet and doPost in servlet. So how is it possible to use Post and Get at the same time.

I am used to do this in PHP and other web programming languages (sending page selection and action info with URL and form data using Post, then creating pages using MVC pattern) but now I see there are two separate methods and it seems just one of them is being called.

2- Is it possible for example to access Get info from inside doPost method? Or vise versa?

Regards,
Mac
[ October 21, 2004: Message edited by: Siamak Sarmady ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have a look at the Servlet interface. It defines a method called

This is the generic way servlets handle requests. 99% of the time servlets are uses in conjunction with HTTP requests, which have a variety of request types (GET, POST, PUT, HEAD, DELETE, OPTIONS, TRACE). Rather than requiring developers to implement the service method every time with a conditional statement, Sun's developer's added HttpServlet whose service methods does this for you. You could override the service method to handle all requests in the same way if you wanted to, rather than letting it delegate to the appropriate method (however there are differences as to how the different HTTP requests behave in the Java API). Alternatively, an much more easily, you could just get your servlet's doGet method to call doPost, or vice versa.
 
Siamak Saarmann
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I'm sorry. I did not knew that service method provides that.

Really thank you. I will take a better look next time.

Mac
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's quite alright Siamak Sarmady. Happy to help.
 
rogel garcia
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do the following:
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic