Skip to Content
0
Former Member
May 05, 2006 at 09:06 AM

How to call a Servlet

721 Views

Hi there,

I am new to Netweaver and I need to create a web-application based on JSP and Servlets. My project has got the following structure:

EAR-Project: Testproject

Webproject: ServletTest

- source: com.company.IndexServlet

public class IndexServlet extends HttpServlet{

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

PrintWriter pw = response.getWriter();

pw.println("<html><head>IndexServlet</head><body>Das ist der Text</body></html>");

}

}

- web.xml

<web-app>

<display-name>Testme</display-name>

<description>WEB APP description</description>

<servlet>

<servlet-name>IndexServlet</servlet-name>

<servlet-class>com.company.IndexServlet</servlet-class>

</servlet> <servlet>

<servlet-name>Index.jsp</servlet-name>

<jsp-file>/Index.jsp</jsp-file>

</servlet>

</web-app>

- webContent: Index.jsp

<%@ page language="java" %>

<html>

<head>

<title>

Title

</title>

</head>

<body>

<h1>

I am the index content

</h1>

<form name="formular" method="post" action="/IndexServlet">

<input type="submit" value="Go ..."/>

</form>

</body>

</html>

When I press the button in the jsp, I get a 404 error. Can someone help me to solve the problem? How do I call servlets by URL?

Thanks for help.

Regards,

Thomas