Results 1 to 6 of 6
  1. #1
    allayahassine is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Servlet Test Problem

    Hello,

    I'm new in Java EE. I'm developing my first servlet ever. This is the Java class for the servlet

    Java Code:
    package com.hassine.servlets;
    
    import javax.servlet.http.HttpServlet;
    
    public class PremierServlet extends HttpServlet{
    
    }
    This is the HTML page's code

    Java Code:
    <html>
      <head>
        <meta charset="utf-8" />
        <title>Test</title>
      </head>
      <body>
        <p>Ceci est une page HTML.</p>
      </body>
    </html>
    and this is the mapping in web.xml

    Java Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
      <servlet>
        <servlet-name>PremierServlet</servlet-name>
        <servlet-class>com.hassine.servlets.PremierServlet</servlet-class>
      </servlet>
      <servlet-mapping>
        <servlet-name>PremierServlet</servlet-name>
        <url-pattern>/toto</url-pattern>
      </servlet-mapping>
    </web-app>
    When testing (with Apache Tomcat), an error message occurs in EclipseServlet Test Problem-test.jpg
    Attached Thumbnails Attached Thumbnails Servlet Test Problem-test.jpg  
    Last edited by allayahassine; 07-17-2014 at 03:45 PM.

  2. #2
    allayahassine is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

    Default Re: Servlet Test Problem

    Please ignore the attached image (the second one)

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Servlet Test Problem

    URL pattern of your servlet: /toto
    the URL you are sending your browser to: /test

    There is no mystery here.

    I assume the context name of your application is 'test', so the correct url would be: http://localhost:8080/test/toto
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Servlet Test Problem

    Your xml says '/toto', your screenshot link says '/test'.

    ETA: Blimey, I'm on form today!
    Captain Slooooooooooow!
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  5. #5
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    5,114
    Rep Power
    12

    Default Re: Servlet Test Problem

    Ninja kick, woosh!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  6. #6
    allayahassine is offline Member
    Join Date
    Feb 2014
    Posts
    4
    Rep Power
    0

Similar Threads

  1. Replies: 12
    Last Post: 04-09-2014, 02:10 PM
  2. problem with JUnit test
    By exltus in forum Advanced Java
    Replies: 12
    Last Post: 12-19-2011, 07:49 PM
  3. Replies: 3
    Last Post: 06-23-2011, 09:31 PM
  4. junit test problem
    By moamen in forum Eclipse
    Replies: 2
    Last Post: 03-14-2010, 09:41 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •