Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Problem with JSP and Servlets..

Options
  • 15-04-2005 8:55pm
    #1
    Closed Accounts Posts: 113 ✭✭


    I've got a page, form.jsp, which passes it's form values onto a Mail servlet. The servlet then (in theory) e-mails the values to a specified e-mail address. The directory structure for the web app is as follows:
    + [U]public_html[/U]
        * index.jsp
        * form.jsp
        + [U]WEB-INF[/U]
            + [U]classes[/U]
                + [U]com[/U]
                    + [U]domain[/U]
                        + [U]serlvets[/U]
                            * MailServlet.class
            + [U]lib[/U]
                * mail.jar
                * activation.jar
            * web.xml
    

    I figured I had the web.xml correct, but it seems to mess up the processing of every JSP page (I get Tomcat 404 errors, even after deleting it). As a result, none of my JSP pages are accessible now.

    I'll list my web.xml contents in the next post. Could someone please help me with it? Also, in the "action" attribute of the form tag, what should I put? I haven't mapped servlets before.


Comments

  • Closed Accounts Posts: 113 ✭✭Pinhead



    WEB.XML
    :
    <?xml version="1.0" encoding="ISO-8859-1"?>
    
    <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
    
    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
        version="2.4">
    
        <display-name>Web site</display-name>
        <description>
          Yadda yadda
        </description>
    
        <servlet>
            <servlet-name>MailServlet</servlet-name>
            <servlet-class>com.domain.servlets.MailServlet</servlet>
        </servlet>
    
        <servlet-mapping>
            <servlet-name>MailServlet</servlet-name>
            <url-pattern>/MailServlet</url-pattern>
        </servlet-mapping>
    
    </web-app>
    


  • Registered Users Posts: 4,287 ✭✭✭NotMe


    action = "/MailServlet"


  • Closed Accounts Posts: 113 ✭✭Pinhead


    That's what I had. Still getting some lovely Tomcat errors though.


  • Registered Users Posts: 1,745 ✭✭✭swiss


    Have you included "public html" in the list of allowed web application folders in the server.xml file in the TOMCAT_HOME/conf directory?

    What I mean is, assuming you have the public html directory in TOMCAT_HOME/webapps/, you would need to have the following code or something similar in the server.xml file to access this directory.
    <Context path="/public html" docBase="public html" debug="0"
    reloadable="true">
    

    Also, I'm not sure if Tomcat likes spaces. Try renaming the public html directory to public_html if that fails.


  • Closed Accounts Posts: 113 ✭✭Pinhead


    I know how to set-up a context path- it works fine on my side of things. However, I'm trying to run it on an online server so I can't edit the server.xml file.


  • Advertisement
  • Closed Accounts Posts: 92 ✭✭tempest


    <servlet-class>com.domain.servlets.MailServlet</servlet>

    + classes
    + com
    + domain
    + serlvets
    * MailServlet.class


  • Closed Accounts Posts: 113 ✭✭Pinhead


    If only it were that simple. That's not a server-side typo. It just applied to that post. *sigh*


Advertisement