aspose file tools*
The moose likes Servlets and the fly likes Using Post and Get at the same time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Using Post and Get at the same time" Watch "Using Post and Get at the same time" New topic
Author

Using Post and Get at the same time

Siamak Saarmann
Ranch Hand

Joined: Aug 21, 2004
Posts: 78
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 ]

PhD Artificial Intelligence, OCJP1.6
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Siamak Saarmann
Ranch Hand

Joined: Aug 21, 2004
Posts: 78
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

Joined: Apr 14, 2004
Posts: 10336

That's quite alright Siamak Sarmady. Happy to help.
rogel garcia
Ranch Hand

Joined: Dec 19, 2003
Posts: 41
Do the following:


SCJP 1.4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Post and Get at the same time