JSP/Servlet Basic Knowledges

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

  1. Comment
  2. Statement
  3. Output expression
  4. 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

  1. application start
    • in this way, you show state in web.xml
  2. 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.

  1. write the java class.
  2. create TLD(Tag Library Definition) file.
  3. State to use the TLD by compile CMD taglib in jsp page.

Filter

Seemed to be a enhanced version of servlet.
To use Filter:

  1. create a Filter class
  2. regist it in web.xml

Create a Filter

Must implements javax.servlet.Filter interface, which has methods:

  1. void init(FilterConfig config)
  2. void destroy()
  3. void doFilter(...)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值