Results 1 to 2 of 2

Thread: Error 405

  1. #1
    Jeremy720 is offline Member
    Join Date
    Oct 2008
    Posts
    13
    Rep Power
    0

    Default Error 405

    Hello. I'm getting a 405 error...The specified HTTP method is not allowed for the requested resource (HTTP method GET is not supported by this URL).

    It works until I include the
    <%@ taglib prefix="c" uri="...://java.sun.com/jsp/jstl/core" %>
    <%@ taglib prefix="myTags" tagdir="/WEB-INF/tags" %>
    directives and try to access them.

    sorry if this is messy. (side note: what is the preferred method for posting code?)

    Confirmation.jsp
    <html>
    <head>
    <title>Thank you</title>
    </head>
    <body>
    <myTags:Header/>
    <%--<jsp:include page="Header.jsp" >
    <jsp:param name="subTitle" value="Success!" />
    </jsp:include>--%>
    <%--<c:import url="Header.jsp" >
    <c:param name="subTitle2" value="This is from the tag import" />
    </c:import>--%>
    <% Cookie cookie = (Cookie)session.getAttribute("username"); out.println(cookie.getValue());%>

    ${sessionScope.state}
    <h1>
    You have sucessfully logged in,
    <%--<c:out value='${cookie.username.value}' default='guest' />--%>
    ${cookie.username.value}
    </h1>
    <h2><br/>
    Session creation time was,
    ${sessionScope.sessionTime}

    Current time is,
    ${requestScope.currentTime}
    </h2><br/>
    <hr/>
    Song List:<br/>
    <c:forEach var="song1" items="${songList}" >
    ${song1} <br/>
    </c:forEach>
    <hr/><% taglib prefix="mine" uri="randomThings"%>
    Random Advice:<br/>
    <mine:advice user="${userName}" />
    <a href="<c:url value='Login.jsp' />">Back to login</a><%--<c:url ...> URL rewriting to ensure the jsessionid is appended to the URL --%>
    <br/><br/>
    <a href="killSession">Destroy session and login Again</a>
    </body>
    </html>
    Login.jsp
    <%@page session="false"%>
    <html>
    <head>
    <script type="text/javascript">

    function check(element, message)
    {
    with (element)
    {
    if (value==null||value=="")
    {
    alert(message);
    return false;
    }
    else
    {
    return true;
    }
    }
    }

    function validate(thisform)
    {
    with (thisform)
    {
    if (check(username,"Username must be filled out!")==false)
    {
    username.focus();
    return false;
    }
    if (check(id,"Id must be filled out!")==false)
    {
    id.focus();
    return false;
    }
    }
    }
    </script>

    </head>
    <body>
    <form id="form" method="post" onsubmit="return validate(this)" action="login">
    <%
    String cookieName =
    com.project5.CookieUtility.getCookieValue
    (request, "username", "Enter Name");
    String username = cookieName;
    %>

    username: <input type="text" name="username" value="<%=username%>" /><br/>
    id: <input type="text" name="id" /><br/>

    <input type="submit"value="Login"/>
    </form>
    </body>
    </html>
    LoginServlet.java
    public class LoginServlet extends HttpServlet
    {
    public void doPost(HttpServletRequest request,
    HttpServletResponse response)
    throws IOException, ServletException
    {
    response.setContentType("text/html");
    String[] songList = {"Don't stop believing", "Shot through the heart", "You're mama don't dance"};
    String name = request.getParameter("username");
    String id = request.getParameter("id");

    Cookie cookie = new Cookie("username", name);
    cookie.setMaxAge(60*60);
    response.addCookie(cookie);

    HttpSession session = request.getSession();
    session.setMaxInactiveInterval(60*60);
    session.setAttribute("username", cookie);
    session.setAttribute("sessionTime", new Date(session.getCreationTime()));
    request.setAttribute("currentTime", new Date());
    request.setAttribute("songList", songList);

    String sessionState;

    if(session.isNew())
    {
    sessionState = "New session";
    }
    else
    {
    sessionState = "Session Exists";
    }

    session.setAttribute("state", sessionState);

    RequestDispatcher rd =
    request.getRequestDispatcher("/Confirmation.jsp");
    rd.forward(request, response);
    }
    }
    Any help would be appreciated. I don't know why I'm getting the error

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    7

    Default

    Apparently somewhere a GET is being sent to your servlet which has not overridden the doGet method.

Similar Threads

  1. Replies: 3
    Last Post: 01-23-2009, 08:53 AM
  2. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •