I'm also trying to forward to a JSP from a servlet.
I had planed on having the user log into a standard html page
that would send off a post request to a login servlet which would
then foward to a JSP page.   But i keep getting a

-----------------------------------------
Error: 405
HTTP method POST is not supported by this URL
-----------------------------------------

thrown.   The JSP that i'm forwarding to is really basic
"Hello i'm hear". From the error message i'm getting i'm thinking
i might need some kind of POST handling in the JSP i'm forwading
to but don't know what that might be (That or the error message is just
a red herring).

I've also attached the code (below) in my doPost Method in my login Servlet.
Any help would be grrrreatly appreciated.

Thanks in advance.

Kelsey.

=======================================

    public void doPost(HttpServletRequest request, HttpServletResponse res)
throws IOException, ServletException
    {
        //Just getting info from the post call
        String msgBoxNum = request.getParameter(MSGBOX_NUM);
        String msgBoxPin = request.getParameter(MSGBOX_PIN);

        //forward to msg box JSP
        try {

            RequestDispatcher dispatcher =
getServletConfig().getServletContext().getRequestDispatcher("/jsp/jsptoserv/
hello.jsp");

            if (dispatcher == null){
                    PrintWriter out = res.getWriter ();
                res.setContentType("text/html");

                out.println("Could not forward to msgbox.jsp page.  URI
error.");
            }

            dispatcher.forward(request, res);

        }
        catch (ServletException ex) {       ex.printStackTrace ();      }




At 05:15 PM 1/11/00 +0000, you wrote:
>Elisabeth,
>
>you are not doing a 'forward' in the JSP/Servlet sense of the word, you are
>doing a redirect. The redirect causes the web server to send a re-direct
>header back to the browser, the browser then does another request to the
>server. My guess is that all your problems stem from this. Try using a
>RequestDispatcher to forward the request to the JSP and not use re-direct,
>the 'forward', forwards the request within the servlet/JSP engine (there is
>no round-trip involved - BTW round trips are evil),
>
>Kevin Jones
>DevelopMentor
>
>-----Original Message-----
>From: A mailing list about Java Server Pages specification and reference
>[mailto:[EMAIL PROTECTED]]On Behalf Of Elisabeth Freeman
>Sent: 11 January 2000 15:47
>To: [EMAIL PROTECTED]
>Subject: help!
>
>
>I am forwarding to a JSP from a servlet, and attempting to put one bean
>in the application scope (by putting it in the servlet context) and one
>bean in the session.
>
>The JSP can see the bean in the servlet context, but the values that I
>set in it before the forward are not there, and the JSP can't see the
>session bean at all (ie, it's null when I retrieve it from the session.
>
>Here's a code snippet.  Any help would be much appreciated!  Please copy
>my email address when responding as I only get the digest format of the
>mailing list.
>
>Thanks, Beth
>
>Here's the servlet code:
>
>         SystemBean systemBean = new SystemBean();
>         getServletContext().setAttribute("systembean", systemBean);
>         String scheme = request.getScheme();
>         String host = request.getServerName();
>         int port = request.getServerPort();
>         systemBean.setServletPath(scheme, host, port);
>         systemBean.setJspPath(scheme, host, port);
>
>         String user = request.getParameter("user");
>         String password = request.getParameter("password");
>
>         HttpSession theSession = request.getSession(true);
>         UserBean userBean = new UserBean();
>         userBean.identity.setUser(user);
>         userBean.identity.setUserName(user);
>         userBean.identity.setUserEmail("[EMAIL PROTECTED]");
>         theSession.putValue("userbean", userBean);
>
>         response.sendRedirect("http://" + host + ":" + port +
>"/examples/jsp/Here.jsp");
>
>and here's the JSP code:
>
><%@ page info="Test JSP"
>    import="beans.UserBean"
>    errorPage="../Error/Error.jsp" %>
><jsp:useBean id="systemBean" scope="application"
>   class="beans.SystemBean" />
><%
> String errorMsg = "";
> HttpSession mySession = request.getSession();
> if (mySession == null) {
>  errorMsg += "Session is null<BR>";
> }
>
> if (systemBean == null) {
>  errorMsg += "System bean is null<BR>";
> }
>
> UserBean userBean = (UserBean) mySession.getValue("userbean");
> if (userBean == null) {
>  errorMsg += "User bean is null<BR>";
> }
>
>%>
>
>The result is that the system bean is NOT null, but the user bean is.
>However, the values in the system bean ARE null.   I tried using a
>usebean directive for the userBean as well, and got the same results.
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
>FAQs on JSP can be found at:
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to