String ecompany = request.getParameter(\ EmployeeBean employee = new EmployeeBean(); employee.setEno(eno);
employee.setEname(ename);
employee.setEcompany(ecompany);
request.setAttribute(\ RequestDispatcher view =
request.getRequestDispatcher(\ view.forward(request, response); } }
(3):web.xml
(4):EmployeeBean.java package com.beans;
public class EmployeeBean { private String eno = \ private String ename = \ private String ecompany = \
public EmployeeBean() {
}
public void setEno(String eno){ this.eno = eno; }
public void setEname(String ename){ this.ename = ename; }
public void setEcompany(String ecompany){ this.ecompany = ecompany; }
public String getEno(){ return eno; }
public String getEname(){ return ename; }
public String getEcompany(){ return ecompany; } }
(5):displayEmployee.jsp
<%@ page contentType=\
雇员的信息如下:
雇员号:${employee.eno} 雇员名:${employee.ename} 公司名:${employee.ecompany}
4:
(1):Compute.java package com.demo; public class Compute{
public static int add(String x,String y){ int a = 0; int b = 0; try{ a = Integer.parseInt(x); b = Integer.parseInt(y); }catch(Exception e){
System.err.println(\}
return a+b; } }
(2)sum.jsp
<%@ page contentType=\
<%@ taglib prefix=\
计算两个整数之和
两个整数的和为:${demo:add(param[\ (3):taglib.tld
xmlns:xsi=\ xsi:schemaLocation=\ http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd\ version=\
(1)Functions.java
package com.function; import java.util.*;
public class Functions { public static String oldString(String text) { return text; }
public static String reverse( String text ) {
return new StringBuffer( text ).reverse().toString(); }
public static int numVowels( String text ) { String vowels = \ int result = 0;
for( int i = 0; i < text.length(); i++ ) { if( vowels.indexOf( text.charAt( i ) ) != -1 ) { result++; } }
return result; }
public static String caps( String text ) { return text.toUpperCase(); }
public static boolean palinDrome(String str){ StringBuffer sb = new StringBuffer(str); if((sb.reverse().toString()).equals(str)){ return true; }else{ return false; } } }
(2)func.tld
xmlns:xsi=\ xsi:schemaLocation=\ http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd\ version=\
<%@ page contentType=\
<%@ taglib prefix=\
函数功能
you entered: ${function:oldString(param[\
After reversing: ${function:reverse(param[\
After counting vowels: there are ${function:numVowels(param[\
After exchanging:${function:caps(param[\
After judging: the text weather is palinDrome? ${function:palinDrome(param[\