Jsp + java class + servlet implement file read and write functions (3)

Source: Internet
Author: User
This article is based on the implementation of the tomcat platform. The file directory is:
Under tom_homewebappsews:
└ Html
✓ WEB-INF
Classes
└ Com
Using FileMan. class
└ FileServlet. class
Web. xml
Next, modify web. xml to make filesevelet effective /*
<? Xml version = "1.0" encoding = "ISO-8859-1"?>
<! DOCTYPE web-app
PUBLIC "-// Sun Microsystems, Inc. // DTD Web Application 2.3 // EN"
Http://java.sun.com/dtd/web-app_2_3.dtd>
<Web-app>
<Display-name> Welcome to Tomcat </display-name>
<Description>
Welcome to Tomcat
</Description>
<! -- JSPC servlet mappings start -->
<Servlet>
<Servlet-name> org. apache. jsp. index_jsp </servlet-name>
<Servlet-class> org. apache. jsp. index_jsp </servlet-class>
</Servlet>

<Servlet-mapping>
<Servlet-name> org. apache. jsp. index_jsp </servlet-name>
<Url-pattern>/index. jsp </url-pattern>
</Servlet-mapping>
<Servlet>
<Servlet-name> FileServlet </servlet-name>
<Servlet-class> com. FileServlet </servlet-class>
</Servlet>
<Servlet-mapping>
<Servlet-name> FileServlet </servlet-name>
<Url-pattern>/servlet/FileServlet </url-pattern>
</Servlet-mapping>
<! -- JSPC servlet mappings end -->
</Web-app>
Enter http: // localhost: 8080/news/servlet/FileServlet in the browser
OK. The following items are displayed: test.htm and OK can be found under newshtml!

Related Article

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.