| Author |
Can we change default method from GET to POST
|
Ram Chhabra
Ranch Hand
Joined: Jan 07, 2008
Posts: 48
|
|
Hi, I am having one URL as below and having one corresponding servlet to that as Java Class. URL: http://localhost:8080/myapp/test My Code is working fine but by default the GET method is being called in my Servlet. I dont want to call the doGet() method by default, i want to call do Post(), can i do that and i am not using any JSP page, i am directly pasting the above URL in browser and pressing enter Thanks, Ram
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
No. If you type in an URL in the browser, then the browser will send an HTTP GET request. There is no way you can change the behaviour of the browser so that it sends a POST request when you type in an address in the address bar. What is the reason why you would want that?
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
Ram Chhabra
Ranch Hand
Joined: Jan 07, 2008
Posts: 48
|
|
Thanks for reply. I just want because my URL is more then allowed limit for GET i.e. 1024 bytes.
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 12907
|
|
Why do you have such an incredibly long URL? You could make a new page with a much shorter URL, put a form on that page with method="POST", and then add some JavaScript to automatically post the form to the page that you want to get to.
|
 |
aleem khan
Ranch Hand
Joined: Aug 07, 2008
Posts: 94
|
|
Could you try in this way? --------------- doGet(){ doPost(); } ---------------- Like doGet() method inturn calling doPost() observe if long URL works
|
SCJP(1.4), SCWCD, Oracle 9i SQL certified, Oracle PLSQL Developer Certified Associate
|
 |
kishukishor patil
Greenhorn
Joined: Nov 20, 2008
Posts: 23
|
|
|
If your url is such big then why don't you pass the parameters in HttpServletRequest variables setParameter() method...
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56157
|
|
|
There is no such method as setParameter. ikf you meant setAttribute, that's not applicable in this case.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
 |
|
|
subject: Can we change default method from GET to POST
|
|
|