Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Are you sure your url patterns are correct? Try something like this:</p> <pre><code>@WebServlet( name="ListServlet", displayName="ListServlet", urlPatterns = {"/list","/modify", "/search"}, loadOnStartup=1) </code></pre> <p>If you want all the patterns go into the same servlet. If not, you would have to have a different servlets for each pattern, and those servlets should be named differently I guess.</p> <p>Anyway, for this kind of behaviour I would recommend using for example <a href="http://www.restlet.org/" rel="nofollow">Restlet</a> routing.</p> <p><strong>EDITED:</strong></p> <p>I tested it. Here you have my servlets working like a charm:</p> <pre><code>import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(asyncSupported = false, name = "HelloServlet1", urlPatterns = {"/hello1"}) public class TestServlet extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.write("&lt;h2&gt;Hello Servlet One &lt;/h2&gt;"); out.close(); } } </code></pre> <p>and the second one:</p> <pre><code>import java.io.IOException; import java.io.PrintWriter; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(asyncSupported = false, name = "HelloServlet2", urlPatterns = {"/hello2"}) public class TestServlet2 extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); PrintWriter out = resp.getWriter(); out.write("&lt;h2&gt;Hello Servlet Two &lt;/h2&gt;"); out.close(); } } </code></pre> <p>I do call them like: <a href="http://localhost:8080/eetest/hello1" rel="nofollow">http://localhost:8080/eetest/hello1</a> and <a href="http://localhost:8080/eetest/hello2" rel="nofollow">http://localhost:8080/eetest/hello2</a> and they print 'Hello Servlet One' and 'Hello Servlet Two' respectivelly. (tested on JBoss AS 7 - web profile)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload