Steps To Create Servlet Application in Netbeans IDE
Steps To Create Servlet Application in Netbeans IDE
3. The complete directory structure required for the Servlet Application will be created
> Servlet.
response.setContentType("text/html");
out.println("<HTML>");
out.println("<BODY>");
out.println("</BODY></HTML>");
8. Create an HTML file, right click on Web Pages -> New -> HTML
9. Give it a name.
<body>
<INPUT TYPE=SUBMIT>
</FORM>
</body>
To make the form works with Java servlet, we need to specify the following attributes for
o method=”get” or “post” to send the form data as an HTTP GET or POST request to
the server. Generally, form submission should be done in HTTP GET or POST
method.
11. Check web.xml file. In the web.xml file you can see, we have specified the url-pattern and
the servlet-name,
<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>
12. Run your application, right click on your Project and select Run
Output: