File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes goGet vs. doPost  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "goGet vs. doPost  " Watch "goGet vs. doPost  " New topic

goGet vs. doPost

Scott Updike
Ranch Hand

Joined: Feb 16, 2006
Posts: 92
I have a simple problem that I hope someone can point me in the right direction:

I have a simple jsp page where I have a url that passes two parameters to a servlet that is different from the servlet specified in between the <form> tags. When I select the link, I get the following error:

The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

Any idea why I'm getting this error?


Here's the cropped jsp file:

<form method="POST"
<input type="SUBMIT" name="mainbutton" value="Update Issue">
<input type="SUBMIT" name="mainbutton" value="Back to Main">

...lots of code....

<a href="<c:url value='/'><c aram name='issuename' value='${}' /><c aram name='commentid' value='${el.commid}' /></c:url>">Delete</a>

When I move my mouse over the link, the correct parameters show up so the link is correct.

Here's the servlet code for


import javax.servlet.http.*;
import javax.servlet.jsp.jstl.sql.*;
import javax.servlet.*;
import java.sql.*;
import java.util.*;

public class deleteComment extends HttpServlet {

public void doGet (HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {

sqlDAOMySQL sqlConn = (sqlDAOMySQL) getServletContext().getAttribute("dbase");
String deleteName = request.getParameter("issuename");
String Id = request.getParameter("commentid");
Integer deleteId = java.lang.Integer.valueOf(Id);
IssueTO updatedIssue = new IssueTO();

try {

sqlConn.deleteComment(deleteName, deleteId);
updatedIssue = sqlConn.getIssue(deleteName);

RequestDispatcher view = request.getRequestDispatcher("editIssue.jsp");
view.forward(request, response);

} catch (Exception ex) {


} //do post

} //end class

Here's the DD snippet...

ak pillai
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
Your JSP is doing an HTTP POST and your Servlet only has a doGet() method.

What you need to do is add a doPost() method, which just calls your doGet() method. Add the following method in your servlet and you should be fine.

[ July 12, 2006: Message edited by: ak pillai ]

java j2ee job interview questions with answers | Learn the core concepts and the key areas
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63865

Originally posted by ak pillai:
Your JSP is doing an HTTP POST and your Servlet only has a doGet() method.

No, he said that this is a result of clicking the link, not submitting the form.

[Asking smart questions] [About Bear] [Books by Bear]
abhijit Ohal
Ranch Hand

Joined: Mar 10, 2006
Posts: 64
i think you missout '?' after also in your link querry string missout '&' between to request parametrs
see the correct format bellow

I agree. Here's the link:
subject: goGet vs. doPost
jQuery in Action, 3rd edition