Hi all !

If I post a form in the jsp then it execute the doPost of the right servlet.

If the servlet detects an error in the form, I send back to the jsp.

All is OK.
But...

If the jsp has an <c:import url="/form2"/> ( /form2 is a servlet redirecting to 
another jsp, and c:import is the 'core' taglib),
Tomcat do the import with the POST method request and it's the doPOST method of 
my form2 servlet who is executed

Is it a normal way ?

Here's all the code:

WEB.XML


        Code:
                <welcome-file-list>
                <welcome-file>form1.jsp</welcome-file>
        </welcome-file-list>

        <servlet>
                <servlet-name>form1</servlet-name>
                <servlet-class>org.Form1</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>form1</servlet-name>
                <url-pattern>/form1</url-pattern>
        </servlet-mapping>
        <servlet>
                <servlet-name>form2</servlet-name>
                <servlet-class>org.Form2</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>form2</servlet-name>
                <url-pattern>/form2</url-pattern>
        </servlet-mapping>
FORM1.JSP


        Code:
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<body>
<form action="/form1" method="post">
        <input type="text" name="mytext"/>
        <input type="submit" name="mysubmit"/>
</form>
<c:import url="/form2" />
</body>
FORM2.JSP


        Code:
        <body>
<form action="/form2" method="post">
        <input type="text" name="mytext2"/>
        <input type="submit" name="mysubmit2"/>
</form>
</body>
org.Form1.class


        Code:
        public class Form1 extends HttpServlet {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                System.out.println("DOGET INITIALIZING FORM1");
        }
        
        
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                System.out.println("DOPOST FORM1");
                // I detect errors in my form: go back
                req.getRequestDispatcher("/form1.jsp").forward(req, resp);
        }
}


org.Form2.class


        Code:
        public class Form2 extends HttpServlet {

        @Override
        protected void doGet(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                System.out.println("DOGET INITIALIZING FORM2");
                req.getRequestDispatcher("/form2.jsp").forward(req, resp);
        }
        
        
        @Override
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                        throws ServletException, IOException {
                System.out.println("DOPOST FORM2");
        }
}
So, when I submit something with the form 1 it shows:

DOPOST FORM1

DOPOST FORM2



Thanks

                                                          
_________________________________________________________________
Hotmail arrive sur votre téléphone ! Compatible Iphone, Windows Phone, 
Blackberry, …
http://www.messengersurvotremobile.com/?d=Hotmail
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to