Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

About doPost in servlet

 
fadil alnassar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Prasad Babu
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
fadil alnassar
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic