File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » Servlets
Bookmark "About doPost in servlet" Watch "About doPost in servlet" New topic

About doPost in servlet

fadil alnassar

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 '' 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.


Regards<br /><a href="" target="_blank" rel="nofollow"></a>
Prasad Babu
Ranch Hand

Joined: Jul 17, 2005
Posts: 57


Call doPost method in doGet method. thats all.

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

Morgan Christian

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.

- 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)

- 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.


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

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

Joined: Dec 11, 2004
Posts: 13410


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.


[ 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:
subject: About doPost in servlet
It's not a secret anymore!