With attribute label development full process ---- J2EE Small Application 2 (Inber) Tag Application: Data Source MyDataSource2 User SA Password (Empty) Database Pubs Table: Employee
Description: Windows ODBC --- SQL Database PUBS Table: Employee
Function: Search JOB_LVL> = (input value) AND JOB_LVL <= (input value) data record, where you want to call in the JSP page
Call it.
(1) Tag handler: Employeetag.javaPackage Net.inber;
Import javax.servlet.jsp. *; import javax.servlet.jsp.tagext. *;
Import java.util.hashtable; import java.io.writer; import java.io.iOException; import java.util.date;
Import java.sql. *; import java.math. *; import java.util. *;
Public Class EmployeetaG Extends tagsupport {connection con = NULL; Statement State = null; ResultSet RS = NULL;
Private string min; public void setminvalue (string t) {this.min = t;} public string getminvalue () {return this.min;} public void setMaxValue (string m) {this.max = m;} Public string getMaxvalue () {return this.max;}
public EmployeeTag () throws ClassNotFoundException {Class.forName ( "sun.jdbc.odbc.JdbcOdbcDriver");} public int doStartTag () throws JspTagException {return EVAL_BODY_INCLUDE;} public int doEndTag () throws JspTagException {String dateString = new Date () .tostring (); try {pagecontext.get (). Write (""); tryContext.get (); con = drivermanager.getConnection ("JDBC: ODBC: MyDataSource2", "SA", "" ); String strQuery = "select emp_id, fname, lname, job_lvl, hire_date from employee where job_lvl> =" min "and job_lvl <=" max; System.out.println (strQuery); state = con.createStatement () ; rs = state.executeQuery (strQuery); String emp_id = null; String fname = null; String lname = null; String job_lvl = null; String hire_date = null; out.write ( "