JSP page access servlet path error 404 in self-built directory

Source: Internet
Author: User

---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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.