0

I have a plugin project where I want to implement some servlets with jetyy. I have a login.html with this structure:

<!DOCTYPE html PUBLIC "-//IETF//DTD HTML 2.0//EN">

<html>

    <head>
        <title>LOGIN.HTML</title>
    </head>

    <body>
        <h1>LOGIN</h1>

        <form method='POST' action=''>
            User: <input type="text"> <br />
            Password: <input type="password"> <br />
            <input type="submit" value="login">
        </form>

    </body>

</html>

After I submit the form, I want to call a servlet to do some actions... This is the servlet:

import java.io.IOException;

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("/receptor")
public class HelloServlet extends HttpServlet
{
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException {

    }

    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
        throws ServletException, IOException
    {
        System.out.println("TEST");
    }
}

But I can't call it, I always have the 404 not found error, what's the right thing to write on the action of the form ?

PS: I've tried to create the WEB-INF structure and the web.xml, but I always got bad configuration error of this web.xml .. Is it possible to call the servlet without web.xml ?

yat0
  • 967
  • 1
  • 13
  • 29
  • Post your web.xml please :D – Ben Dale Jan 08 '14 at 10:44
  • I didn't have one, it's a plugin project.. I've tried to create a web.xml but I always got bad configuration error, I forgot to mention that @BenjaminDale – yat0 Jan 08 '14 at 10:46
  • 1
    Well usually, you'd reference your servlet in web.xml and give it a name to reference it by. That name is what you'd put in action. E.g. HelloServlet – Ben Dale Jan 08 '14 at 10:51
  • 1
    http://pubs.vmware.com/vfabric53/index.jsp?topic=/com.vmware.vfabric.tc-server.2.9/getting-started/tutwebapp-web-xml-file.html - See here – Ben Dale Jan 08 '14 at 10:52
  • Should I move my servlet class to the WEB-INF classes folder ? @BenjaminDale – yat0 Jan 08 '14 at 10:56
  • 1
    http://stackoverflow.com/questions/19786142/what-is-web-inf-used-for-in-a-java-web-application - This should help clear things up for you. And also this: http://www.doc.ic.ac.uk/csg-old/java/servlets/servlets.html – Ben Dale Jan 08 '14 at 10:59

0 Answers0