Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: 404 Status Error

  1. #1
    Junior Member
    Join Date
    Aug 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy 404 Status Error

    web.xml file

    <web-app>
    <servlet>
    <servlet-name>MyServlet</servlet-name>
    <servlet-class>MyServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>MyServlet</servlet-name>
    <url-pattern>/MyServlet</url-pattern>
    </servlet-mapping>
    </web-app>

    MyServlet.java


    import java.io.*;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;


    public class MyServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    PrintWriter out=response.getWriter();
    response.setContentType("text/html");

    int x=Integer.parseInt(request.getParameter("n1"));
    int y=Integer.parseInt(request.getParameter("n2"));
    out.println("The addition of numbers is "+ (x+y));


    }
    }



    login.html
    <h1>Mathematical Functions</h1>
    <body>
    <form action="MyServlet" method="get">
    First number:<INPUT type="number" size="5" name="n1"><br>
    Second number:<INPUT type="number" size="5" name="n2">
    <br>



    <input type="submit" value="Submit">
    </form>
    </body>


    I am getting the folllowing error .
    type Status report

    message /f/

    description The requested resource (/f/) is not available.



    f.war is the file i created.
    Everything like installing, jdk, apache tomcat is perfect as i have run other programs using the same process. Please help me in solving this error


  2. #2
    Junior Member
    Join Date
    Aug 2012
    Location
    Virginia, USA
    Posts
    3
    My Mood
    Confused
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: 404 Status Error

    preeti91...if you don't have a default page and don't specify MyServlet in the URL then you will get a 404.

    Did you try .../f/MyServlet ?

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: 404 Status Error

    First, to start from your login.html page, either you need to map it on your deployment descriptor(web.xml), then do HOST_NAMEORT and after that, in your login.html, put in the form tag, the action attribute which would actually request container for your servlet. If you still facing the problem, let us know.
    Anyone who stops learning is old, whether at twenty or eighty. Anyone who keeps learning stays young. The greatest thing in life is to keep your mind young.

    - Henry Ford

Similar Threads

  1. HTTP Status 500
    By giri121 in forum Exceptions
    Replies: 5
    Last Post: April 10th, 2012, 09:58 AM
  2. HTTP Status 404
    By Star_pro in forum Java Servlet
    Replies: 0
    Last Post: February 28th, 2011, 02:17 PM
  3. Checking the Status of a checkbox
    By michaelz in forum Object Oriented Programming
    Replies: 16
    Last Post: August 9th, 2010, 06:44 AM
  4. HTTP Status 500 -
    By mqt in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 6th, 2010, 01:09 AM
  5. Need java code to know the browser status
    By newnewgen in forum Java Theory & Questions
    Replies: 2
    Last Post: January 8th, 2010, 11:39 PM