Web Stucture Hierarchy & web.xml
Hierarchy
- WEB_INF
- classes
- lib
- web.xml
- *.jsp
web.xml
Configure:
- Direct page.(The one user get with path “/” or “”)
<welcome-file-list>
JSP
Jsp is indeed a servlet, just wrapped with a friendly appearance.
Basic Grammar
- Comment
- Statement
- Output expression
- Little script
Compile CMDs
page
<%@ page import="java.sql.*"%>
include
<%@ include file="header.jsp"%>
taglib
Action CMDs
Format:
<jsp:[action] someparam="somestrs"/>
Or
<jsp:[action] someparam="somestrs"/>
(<jsp:param.../>)
</jsp:[action]>
forward
param
include
Compile CMDs in the included page will be disabled. Only insert its body to the current page.
plugin
Refer to Applet, seldom used now.
useBean
setProperty
getProperty
Integreted Objects
PageContent
It has 4 scopes, reflecting application, page, session, request.
PageContent almost can do anything you are able to.
application
page
Seldom used because it can be replaced with this in a servlet object.
session
request
config
exception
out
pageContent
Servlet
develop
configure
web.xml
Life Cycle
Start
- application start
- in this way, you show state in web.xml
- First time user access the servlet.
Die
When the server decide(or be decided) to close.
JSP DIY tags
Java Specification demand the TLD file in any sub path of WEB_INF.
- write the java class.
- create TLD(Tag Library Definition) file.
- State to use the TLD by compile CMD
taglib
in jsp page.
Filter
Seemed to be a enhanced version of servlet.
To use Filter:
- create a Filter class
- regist it in web.xml
Create a Filter
Must implements javax.servlet.Filter interface, which has methods:
void init(FilterConfig config)
void destroy()
void doFilter(...)