aspose file tools*
The moose likes Servlets and the fly likes About doPost in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "About doPost in servlet" Watch "About doPost in servlet" New topic
Author

About doPost in servlet

fadil alnassar
Greenhorn

Joined: Dec 16, 2005
Posts: 4
hi !!

i am beginner in JAVA and i wish you can help me.

assume that i have a servlet called 'servlet1.java' i need to call it using its doPost method NOT the doGET?

can some one tell me how is that as i know that if i use the url i will call the doGET and i read about calling the doPost with the doGet as a bad practice ... so i need another way to do it.

Thanks


Regards<br /><a href="http://www.fadilalnassar.com" target="_blank" rel="nofollow">www.fadilalnassar.com</a>
Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57
Hi,

Simple!!

Call doPost method in doGet method. thats all.



By the above code, whatever calling method, doPost will be excuted.

Bye.
Morgan Christian
Greenhorn

Joined: Apr 06, 2005
Posts: 7
Howdy, After a few servlet experiences I set my rule of thumb about which one to use and when.

doGet
- Data is going OUT ONLY (I'm not putting anything into a database or file..)
- I have encapsulated several functions and i'd like them to respond to the same url but accept different arguments.
- servlet might lend itself to being bookmarked or is the direct content generator(keeping it's arguments defines the content)

doPost
- Data is going in (into a database or file).
- or anytime I simply don't want stuff in the url

That's how I decide on which one to use... Hope that helps you identify what you need.

cheers
-M


**<br />Still trying to code myself out of this wet paper bag...
fadil alnassar
Greenhorn

Joined: Dec 16, 2005
Posts: 4
is that only way to use is to call the doPost in doGet??

whati need to do, i need to send XML file to a server to get results using the doPost while at the moment i have doGet it send URL so i need to change the methodologey... i hope you understand what i need to do.

thanks for your reply and i wish you can reply to this reply
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

No,

If you create an HTML form and set the method to post, the code in your servlet's doPost method will be executed when the form is submitted.

Example:

[ December 17, 2005: Message edited by: Ben Souther ]

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: About doPost in servlet
 
Similar Threads
With respect to servlets
doPost(), doGet()
Invoking doPost() method of a servlet from another servlet
Confusion about servlet generated from JSP
Call servlets in Flex