In Java development, a detailed explanation of the folder Web-inf (especially the statements in Web.xml)

Source: Internet
Author: User
Tags error handling http error code 404
<web-app> </web-app>
Indicates that this is a Web application.

<context-param>
<param-name> JSP </param-name>
<param-value> Javac </param-value>
</context-param>
Specifies that the Java compiler javac should be used when establishing this application.
<servlet>
<servlet-name> HelloServlet </servlet-name>
<servlet-class> Hello </servlet-class>
</servlet>
Specifies the contained servlet class.
<welcome-file-list>
<welcome-file>/helloservlet </welcome-file>
</welcome-file-list>
Specifies which servlet is triggered by default when a user accesses a Web application.
<servlet-mapping>
<servlet-name> HelloServlet </servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
Specifies which URL pattern the HelloServlet should map to.

<display-name> Simple </display-name>
Specify the name to use when displaying the application

<context-param>
Specifies the parameters to be included in the ServletContext

<session-config>
Specifies the default timeout value to use for HTTP session objects

<error-page>

Specifies the error handling to use when HTTP error code 404 occurs.

-----------------------------------------

Let me add: With regard to web.xml, the main function of the file is to configure the servlet, so I'll introduce the meaning of the servlet configuration entry.
<servlet>
<servlet-name> Task </servlet-name>
<servlet-class> Com.servlet.MyServlet </servlet-class>
</servlet>
The task here is the class name of the servlet you defined (for example, you define a Task.java as a servlet)
The com.servlet.MyServlet here is the path to your servlet class. For WebLogic, the default Access file root directory is Defaultwebapp (of course), so your task.class file should be placed under the Defaultwebapp/com/servlet/myservlet folder, Otherwise the system will not be found.
<servlet-mapping>
<servlet-name> Task </servlet-name>
<url-pattern> task/* </url-pattern>
</servlet-mapping>
The task here is to define which servlet the servlet map is to look for, which is defined as looking for the tast servlet, and of course you can define other servlet classes.
Here to explain the concept of mapping, may be for beginners weblogic for mapping is very puzzled, do not know what dongdong.
<url-pattern> task/* </url-pattern> As far as this configuration is concerned, it refers to the index.html path (typically http://localhost:7001/) that is accessed by default. Join the task directory (http://localhost:7001/task; or http://localhost:7001/task/*.*) as long as you typed these two in the IE address bar, The system will look for the task servlet to process the submitted data (this is a task, defined in <servlet-name> task </servlet-name>).
As for saying *.* is what, the general default is Index.html is
<welcome-file-list>
<welcome-file> index.html </welcome-file>
</welcome-file-list>
The default Access file defined in the

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.