---restore content starts---
JSP page access servlet path error 404 in self-built directory
Using Eclipse-built projects, you will always encounter path problems, such as JSP page Access servlet,jsp in the default path, JSP access path in the self-built directory (web. Xml URL) is different. If the access path is not set, there will always be a headache of 404 access results:
Below is the giveradius.jsp page input radius, which is submitted to the servlet's Computer.java to find the area.
First, the JSP page under the default webconnet
1 Project Structure
2 Web. XML content
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns= "http://xmlns.jcp.org/xml/ Ns/javaee " xsi:schemalocation=" Http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/ Web-app_3_1.xsd "id=" webapp_id " version=" 3.1">
<servlet>
<servlet-name>computer</servlet-name>
<servlet-class>ch7.servlet.Computer</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>computer</servlet-name>
<url-pattern>/getRadius</url-pattern>
</servlet-mapping>
</web-app>
3 giveradius.jsp
<%@ page language="java" contenttype="text/html; Charset=utf-8 "
pageencoding="UTF-8"%>
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" "HTTP://WWW.W3.ORG/TR/HTML4/LOOSE.DTD" >
Cyan><font size=3>
< FORM Action = "Getradius" Method = Post >
<BR> radius of Input circle: <input type=text name=radius>
<input type= submit value=" submit ">
</FORM>
</Font></BODY></HTML>
4 operation results Note the path
Second if giveradius.jsp in the self-built directory, access path needs to be based on the self-built directory to make corresponding changes, JSP page in the Ch7 directory, then Url=/ch7/getradius.
1 Project Structure
2 Web
3 operation results Note that the access path has changed.
JSP page access servlet path error 404 in self-built directory