This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes can we use post method in urlrewriting? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "can we use post method in urlrewriting?" Watch "can we use post method in urlrewriting?" New topic
Author

can we use post method in urlrewriting?

yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
can we use the post method???

if yes what is the reason?
[ October 02, 2008: Message edited by: Bear Bibeault ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
URL rewriting is used for URLs that get sent from the server to the client, whereas POST is a way to transfer data from the client to the server. So the two don't intersect. Can you clarify what you mean?


Ping & DNS - my free Android networking tools app
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
i mean suppose say you have a small program ie servlet can you write a doPost method in it instead of doGet??
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120


[ October 02, 2008: Message edited by: yuvraj kotegar ]
[ October 02, 2008: Message edited by: yuvraj kotegar ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
doGet and doPost are for handling client requests; you can have either or both in a servlet, depending on how it is used. But what do those methods have to do with URL rewriting?
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
because i tried the same above programe with doPost it did'nt work why??
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60794
    
  65

"Didn't work"?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
yuvraj kotegar
Ranch Hand

Joined: Jul 31, 2008
Posts: 120
did not work...

[ October 02, 2008: Message edited by: yuvraj kotegar ]
[ October 02, 2008: Message edited by: yuvraj kotegar ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41134
    
  45
What Bear meant was "what exactly did you try, and how exactly did it not work?" TellTheDetails
arulk pillai
Author
Ranch Hand

Joined: May 31, 2007
Posts: 3219
Sample doGet & doPost



Do you have a form element to test your post




Java Interview Questions and Answers Blog | Amazon.com profile | Java Interview Books
Amit Ghorpade
Bartender

Joined: Jun 06, 2007
Posts: 2716
    
    6

Yuvraj your sample code has only a doGet() method. Now if a HTTP request uses GET, your code will work fine. But if a POST is used, it will fail, since your servlet does not support it.
Refer to arulk's code for a sample implementation of both doGet() and doPost().

Along with the servlet, if you have the security constraints in your DD,then the DD must also support both these methods.


Hope this helps


SCJP, SCWCD.
|Asking Good Questions|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can we use post method in urlrewriting?
 
Similar Threads
Reclaiming memory in java without using garbage collector........
When can we use the method finalize();?? and why do we use it???
doHead
Using GET other than POST
Why calling super to reach a static member is ALWAYS illegal?