aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes About doGet and doPost of Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "About doGet and doPost of Services " Watch "About doGet and doPost of Services " New topic
Author

About doGet and doPost of Services

Swagato Bhatta
Ranch Hand

Joined: Nov 08, 2008
Posts: 72
I have this observation about doGet and doPost of the Services where we spend most of the time....coding

Now in netBeans I have noticed that they do this



My observation is the following. Is it not better this way? I mean this seems to have both doGet and doPost. And both are just calling the same method which doing the job...This might save the trouble of wondering whether the form has doGet or doPost. What do you think?


Working on my SCWCD so I can be a J2EE consultant earning millions of dollars and showing everyone I can
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
doGet and doPost process Request in different way. To process Post request you may look the request body which you don't do in get request. In your case since you are not processing request it doesn't make any difference and you can have a default implementation called form doGet and doPost.


SCJP 1.5(97%) My Blog
Swagato Bhatta
Ranch Hand

Joined: Nov 08, 2008
Posts: 72
shivendra tripathi wrote:doGet and doPost process Request in different way. To process Post request you may look the request body which you don't do in get request. In your case since you are not processing request it doesn't make any difference and you can have a default implementation called form doGet and doPost.


Can you explain bit more? :-) thanks
shivendra tripathi
Ranch Hand

Joined: Aug 26, 2008
Posts: 263
Please ignore whatever I said earlier. Almost all API behave in the same way as shown in your code. The only difference I can see is, since doGet is idempotent so while implementing it you should make sure that there is no side effects of multiple submission of form. But that can be achieved using getMethod of HttpRequest API as well.
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
shivendra tripathi wrote: since doGet is idempotent so while implementing it you should make sure that there is no side effects of multiple submission of form.

How can this be handled ... i mean the issue with multiple submission
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
I mean this seems to have both doGet and doPost. And both are just calling the same method which doing the job...This might save the trouble of wondering whether the form has doGet or doPost. What do you think?

The HTTP specification is very clear that GET and POST are to be used for different purposes; a servlet that uses them interchangeably is thus not in compliance with the HTTP spec, and -if GET is used for purposes where POST should be used, there will be problems. Don't do this.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
Sony Agrawal wrote:How can this be handled ... i mean the issue with multiple submission

Form submissions should be done via POST, not GET. If someone then clicks Reload in the browser, it will warn the user that the form is about to be re-submitted. That's not the case with GET. The Post-Redirect-Get pattern avoids this particular problem (there's an FAQ page about that with more information).
Swagato Bhatta
Ranch Hand

Joined: Nov 08, 2008
Posts: 72
Ulf Dittmer wrote:
Sony Agrawal wrote:How can this be handled ... i mean the issue with multiple submission

Form submissions should be done via POST, not GET. If someone then clicks Reload in the browser, it will warn the user that the form is about to be re-submitted. That's not the case with GET. The Post-Redirect-Get pattern avoids this particular problem (there's an FAQ page about that with more information).


I think PRGP is not in the syllabus of SCWCD. However, I am really interested to find a very simple tutorial on this. Do anyone have a tutorial we can visually look at? Thanks
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
This article should help: http://www.javaranch.com/journal/200603/frontman.html
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About doGet and doPost of Services