Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / February 2005

Tip: Looking for answers? Try searching our database.

JSP / Servlet and HTML Form - HTTP method POST is not supported by this URL

Thread view: 
Nick Havard - 31 Jan 2005 21:32 GMT
Hi

I have the following setup.

A jsp, which includes a second jsp. The second jsp contains a form, which
uses the POST method to call a servlet. The servlet does some validation and
then makes a forward call back to the original jsp.

I have a problem where I get the following error.
=================
405 Method Not Allowed
HTTP method POST is not supported by this URL
=================

I have read that the serlet will use the same method type for a forward
request as was used to call it. In this case that would be POST. I would
have expected the jsp to catch the doPost method, but it doesn't.

How can I overcome this error? Thanks for your help.

Signature

Regards

Nick
news@nickhavardxyz.com

P.S. Remove xyz to reply

Symon - 31 Jan 2005 22:12 GMT
If you use http post, your servlet must ovveride the
doPost(HttpServletRequest req, HttpServletResponse resp) method, not
doGet(req,res).

You can also add this to your servlet to redirect request to the doGet
method :

public void doPost(HttpServletRequest req, HttpServletResponse resp) {
  doGet(req,resp);
}

Symon

> Hi
>
[quoted text clipped - 15 lines]
>
> How can I overcome this error? Thanks for your help.
Nick Havard - 31 Jan 2005 23:03 GMT
Hi

Thanks for your quick response.

The servlet already has the doPost method which gets invoked as expected. To
return back to the original jsp (index.jsp)I use the following two lines of
code.

RequestDispatcher dispatcher = request.getRequestDispatcher("index.jsp");
dispatcher.forward(request, response);

I tried your suggestion of calling doGet from within doPost, but the call to
the index.jsp is still made with a POST, and the error still persists. I
guess the request/response objects are already setup to use POST.

How can I get the index.jsp to implement the doPost method, or get the
index.jsp to catch the POST request under service.

Signature

Regards

Nick
news@nickhavardxyz.com

P.S. Remove xyz to reply

> If you use http post, your servlet must ovveride the
> doPost(HttpServletRequest req, HttpServletResponse resp) method, not
[quoted text clipped - 28 lines]
>>
>> How can I overcome this error? Thanks for your help.
Ryan Stewart - 01 Feb 2005 01:57 GMT
> Hi
>
[quoted text clipped - 9 lines]
> HTTP method POST is not supported by this URL
> =================

I've never seen or heard of something like this. A JSP should have no problem
handling a POST request. Can you post an SSCCE that demonstrates the problem?
(http://www.physci.org/codes/sscce.jsp)
Nick Havard - 01 Feb 2005 20:32 GMT
Hi Symon, Ryan

I've managed to solve the problem.

In the first jsp, there are multiple servlets some of which didn't have the
doPost method overridden. I've added it in so that doPost calls doGet and it
now works.

It seems very strange to me that a call to a servlet uses the same calling
mechanism (i.e. POST) to then call a jsp, which then uses the same mechanism
again to call all jsp's and servlets referred to within.

Thanks for your help.
Signature

Regards

Nick
news@nickhavardxyz.com

P.S. Remove xyz to reply

>> Hi
>>
[quoted text clipped - 13 lines]
> problem handling a POST request. Can you post an SSCCE that demonstrates
> the problem? (http://www.physci.org/codes/sscce.jsp)
Ryan Stewart - 02 Feb 2005 02:02 GMT
[...]
> It seems very strange to me that a call to a servlet uses the same calling
> mechanism (i.e. POST) to then call a jsp, which then uses the same mechanism
> again to call all jsp's and servlets referred to within.
[...]
It has nothing to do with how the servlets call each other and everything to do
with the characteristics of the request which is passed to them.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.