#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    48
    Rep Power
    11

    Question Blank page displayed when html/jsp form submitted to servlet


    Hi,

    I'm hoping someone can help me. I'm using jsp and servlets to create a web form and then submit it to a servlet that processes the form data and sends the user to another jsp page when processing is complete.

    For some reason, when I submit the form, I just receive a blank page on the screen. The url of the browser shows that it is pointing to the correct servlet, but nothing happens. I've checked all of my output logs for error messages and there are none. I've also tried entering System.out.println("inside doGet()"); just inside of the doGet method to see if I could get anything to show up in my output logs, but that doesn't do anything either.

    I'm using resin, if that makes any difference.

    I'll be happy to post more information and code samples if anyone thinks they can help. I just don't want to write pages of information unless there is some hope.

    Thanks in advance,
    Courtenay
  2. #2
  3. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    376
    Originally Posted by Courtenayt
    I'll be happy to post more information and code samples if anyone thinks they can help. I just don't want to write pages of information unless there is some hope.
    There's always hope. No garantees of course, but if you post the form code (from the JSP) and the relevant servlet code, we might be able to help.
    A common mistake people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
    Douglas Adams
  4. #3
  5. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,817
    Rep Power
    3462
    Yes code samples would help.

    Check and make sure that you're using method="get" in your form tag and not method="post"

    Comments on this post

    • stdunbar agrees : Or have doPost() call doGet()
    Dear God. What is it like in your funny little brains? It must be so boring.
  6. #4
  7. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,817
    Rep Power
    3462
    stdunbar agrees: Or have doPost() call doGet()
    I'm actually a big fan of not using "get" at all since "post" doesn't use the url string to pass variables. I only use "get" if I need that type of access.

    Comments on this post

    • wsa1971 agrees
    Dear God. What is it like in your funny little brains? It must be so boring.
  8. #5
  9. AYBABTU
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jul 2004
    Location
    Here or There
    Posts
    1,256
    Rep Power
    376
    On top of that, the amount of data you can transmit is pretty limited using the GET method. Although a specific length is not defined, URI's longer than 255 bytes are not generally supported.

    Comments on this post

    • crownjewel82 agrees : yup
    A common mistake people make when trying to design something completely foolproof is to underestimate the ingenuity of complete fools.
    Douglas Adams
  10. #6
  11. <- My daily commute :^)
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2005
    Location
    Earth. Welcome.
    Posts
    1,501
    Rep Power
    1698
    wsa1971 and crownjewel82: You may wish to read this article about redirect after post before you make everything a post. There are certain disadvantages...
    A -> B: Ride.
  12. #7
  13. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,817
    Rep Power
    3462
    Originally Posted by me
    I only use "get" if I need that type of access.
    In most of the applications I write, most of the problems faced by POST aren't a problem. In the case of duplicate submits usually I have other code in the input validator or in writing to the database that can detect the duplicate entry and if necessary can take steps to prevent it. As they say, there's more than one way to skin a cat.

    I did find the article interesting and i'll probably make use of some of it in some stuff I'm working on.
    Dear God. What is it like in your funny little brains? It must be so boring.
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    48
    Rep Power
    11
    Hi,

    Thanks for your help! I've since learned from my hosting company that I was receiving a file not found error in apache. Unfortuantely I don't have access to those logs to check myself. My problem, although still unresolved is a little bit closer to being figured out.

    Here is what I used to call my servlet when my form was posted
    Code:
    <form action="/teska/processing/FormProcessingServlet" method="post">
    This resulted in the apache page not found error.

    I then tried the following with the direct link to my servlet:

    Code:
    <form action="WEB-INF/classes/teska/processing/FormProcessingServlet" method="post">
    but this caused the following error message:
    403 Forbidden
    Resin 2.1.16 (built Tue Feb 15 11:12:27 PST 2005)
    This was not a surprise because the WEB-INF directory is not accessable from the web for security purposes.

    I'm not sure what I should be using for my form action, and my hosting company hasn't gotten back to me yet either, leading me to beleive they aren't exactly sure what is causing the problem.
    Because of my hosting setup I have a .conf file instead of a web.xml file to hold my servlet mappings. The name of my subdomain is sandbox1, and the following is the subdomain and servlet mapping I have listed in my .conf file for the FormProcessingServlet servlet:

    Code:
     <web-app id='/sandbox1'>
    <classpath id='/home/teska/public_html/sandbox1/WEB-INF/classes' source='/home/teska/public_html/sandbox1/WEB-INF/classes'/>
    <servlet-mapping url-pattern='*.jsp' servlet-name='jsp'/>
    <servlet-mapping url-pattern='*.xtp' servlet-name='xtp'/>
    <path-mapping url-pattern='/servlet/*' real-path='/home/teska/public_html/sandbox1/WEB-INF/classes'/>
    <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    </web-app>
    
    <host id='sandbox1.teska.net'>
    <error-log id='log/error.log'/>
    
    <war-dir>webapps</war-dir>
    
    <web-app id='/' app-dir='/home/teska/public_html/sandbox1' >
    <servlet-mapping url-pattern='*.jsp' servlet-name='jsp'/>
    <servlet-mapping url-pattern='*.xtp' servlet-name='xtp'/>
    <path-mapping url-pattern='/servlet/*' real-path='/home/teska/public_html/sandbox1/WEB-INF/classes'/>
    <servlet-mapping url-pattern='/servlet/*' servlet-name='invoker'/>
    <servlet>
    <servlet-name>jcaptcha</servlet-name>
    <servlet-class>teska.jcaptcha.ImageCaptchaServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping url-pattern='/jcaptcha' servlet-name='jcaptcha'/>
    
    <servlet>
    <servlet-name>FormProcessingServlet</servlet-name>
    <servlet-class>teska.processing.FormProcessingServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet>
    <servlet-mapping url-pattern='/processing' servlet-name='FormProcessingServlet'/>
    
    </web-app>
    </host>
    Here is also some of the relevant parts of my servlet code:

    Code:
    import java.sql.*;
    import java.util.*;
    import teska.dbconn.*;
    import teska.lookup.*;
    
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    
    public class FormProcessingServlet extends HttpServlet{
    
    	public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
    
            System.out.println("FormProcessingServlet.java: inside doGet()");
    
            // do a bunch of form data processing here
    
            RequestDispatcher dispatcher = request.getRequestDispatcher("/submitForm.jsp);
    
            dispatcher.forward(request, response);
    
    
    	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
                    doGet(request, response);
        }
    }
    please let me know if you have any ideas what else I could try. Forgot to add, I'm using Resin instead of Tomcat.

    Thanks,
    Courtenay
  16. #9
  17. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,817
    Rep Power
    3462
    Well for starters you're missing a couple of close brackets there.

    I think your action should be something like servlet/<servlet name including package> as is used in the examples here.
    Dear God. What is it like in your funny little brains? It must be so boring.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    48
    Rep Power
    11

    Smile Thanks!


    Hi,

    Thanks a lot. I changed my form to post to:

    Code:
    <form action="servlet/teska.processing.FormProcessingServlet" method="post">
    I received the following message, which I assume means I'm actually accessing the servlet and need to fix some errors in the code. Please correct me if that assumption is incorrect.

    Code:
    500 Servlet Exception
    
    java.lang.NumberFormatException: null
    	at java.lang.Integer.parseInt(Integer.java:415)
    	at java.lang.Integer.parseInt(Integer.java:497)
    	at teska.processing.FormProcessingServlet.doGet(FormProcessingServlet.java:24)
    	at teska.processing.FormProcessingServlet.doPost(FormProcessingServlet.java:268)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:165)
    	at javax.servlet.http.HttpServlet.service(HttpServlet.java:103)
    	at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:96)
    	at com.caucho.server.http.Invocation.service(Invocation.java:315)
    	at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:346)
    	at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:274)
    	at com.caucho.server.TcpConnection.run(TcpConnection.java:139)
    	at java.lang.Thread.run(Thread.java:595)
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    48
    Rep Power
    11
    Thanks for the note on the missing brackets too - I copied the code from my actual document and forgot to add in the extra bracket on the end. I've also found everyone's input on POST vs GET very interesting and helpful!

    Thanks,
    Courtenay
  22. #12
  23. No Profile Picture
    rebel with a cause
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    May 2004
    Location
    The Batsh!t Crazy State.
    Posts
    5,817
    Rep Power
    3462
    That would be a java code error which means yes you are hitting the servlet. Congratulations.

    Looks like you're trying to do something with a number that doesn't have anything in it.
    Dear God. What is it like in your funny little brains? It must be so boring.

IMN logo majestic logo threadwatch logo seochat tools logo