• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

About doPost in servlet

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic