Static and Dynamic Resources
Manual development of dynamic resources
1. Differences between static and dynamic resources
Static resources: Resources whose source code will never change when users access this resource multiple times.
Dynamic Resource: when a user accesses this resource multiple times, the source code of the resource may be changed.
Dynamic Resource Development Technology
Servlet: Development Technology for writing Dynamic Resources in java.
Servlet features:
1) A common java class that inherits the HttpServlet class and overwrites the doGet Method
2) The Servlet class can only be handed over to the tomcat server for running !!!! (Developers cannot run it themselves !!!)
Servlet manual writing steps:
1) Write a servlet program that inherits HttpServlet
2) Find the class bytecode of the HelloServlet class and copy it to the WEB-INF/classes directory in a web application of tomcat.
3) configure the Servlet in the web. xml file of the current web application.
4) Start the tomcat server and run the access
Access servlet: http: // localhost: 8080/myweb/hello
Dynamic Resources for tool development
1) create a web project (javaweb project)
2) create a static resource file under WebRoot,
3) create a dynamic resource file under src
3.1 new-> Servlet (servlet code generator)
3.2 write pacakge-> class name-> modify mapping url
4) associate with the tomcat server
4.1 window-> Preferences-> MyEcplise-> servers-> Tomcat 6.x (Be sure to enable)
5) Deploy the web project application. (Copy the web application to the tomcat webapps directory)
6) Start the tomcat server
7) Access servlet http: // localhost: 8081/day08_web/hello