Some Templates


1 web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
	id="WebApp_ID" version="3.0">
	<display-name>simpleWebApp</display-name>

	<!-- 上下文 ServletContext 初始化参数-->
	<context-param>
		<param-name>mainEmail</param-name>
		<param-value>songguo.hit@gmail.com</param-value>
  	</context-param>

	<!-- 一个 web应用 -->
	<servlet>
		<servlet-name>servletName</servlet-name>
		<servlet-class>org.songuo.MyServlet</servlet-class>
		
		<!--ServletConfig 初始化参数-->
		<init-param>
			<param-name>adminEmail</param-name>
			<param-value>songguo.hit@gmail.com</param-value>
		</init-param>		
	</servlet>
	<servlet-mapping>
		<servlet-name>servletName</servlet-name>
		<url-pattern>/virtual path/to/urlPatternName</url-pattern>
	</servlet-mapping>

	<!--监听者类-->
	<listener> 
		<listener­class>org.songuo.MyServletContextListener</listener­class> 
  	</listener> 

	<welcome-file-list>
		<welcome-file>index.html</welcome-file>
		<welcome-file>index.htm</welcome-file>
		<welcome-file>index.jsp</welcome-file>
		<welcome-file>default.html</welcome-file>
		<welcome-file>default.htm</welcome-file>
		<welcome-file>default.jsp</welcome-file>
	</welcome-file-list>
</web-app>


2 标记tag  xxx.tld

<?xml version="1.0" encoding="UTF-8"?>
<taglib version="2.0" xmlns="http://java.sun.com/xml/ns/j2ee"
	xmlns:xml="http://www.w3.org/XML/1998/namespace" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd ">
	<tlib-version>2.0</tlib-version>
	<short-name>NMTOKEN</short-name>
	<!--Very important URI-->
	<uri>simpleTags</uri>
	
	<tag>
	<description>menu item example</description>
	<name>menuItem</name>
	<tag-class>org.songuo.MyTagClass</tag-class>
	
	<!--empty/scriptless/tagdependent/JSP-->
	<body-content>scriptless</body-content>
	<attribute>
		<name>itemValue</name>
		<required>true</required>
		<rtexprvalue>true</rtexprvalue>
	</attribute>
	</tag>
</taglib>


3  Servlet

package org.songuo.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CheckCookie extends HttpServlet {
   
    public CheckCookie() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		// ...
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) 
		throws ServletException, IOException {
	}
}


4 JSP

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
</html>


5  Making a Web Application Compatible with Jython

<servlet> 
    <servlet-name>PyServlet</servlet-name> 
    <servlet-class>org.python.util.PyServlet</servlet-class> 
    <load-on-startup>1</load-on-startup> 
	<init-param>
	        <param-name>python.home</param-name>
		<param-value>/path/to/jython</param-value>
	</init-param>
	<init-param>
		<param-name>python.path</param-name>
		<param-value>/path/to/jython/Lib</param-value>
	</init-param>
</servlet> 
 
<servlet-mapping> 
    <servlet-name>PyServlet</servlet-name> 
    <url-pattern>*.py</url-pattern> 
</servlet-mapping>






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值