Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_jsp thread: Why can't i compile this?


Message #1 by "Brandon Ng" <nodnarb_33@y...> on Fri, 25 May 2001 07:29:33
The absolute directory of the two files are d:\program files\apache 
group\jakarta-tomcat\webapps\TravelZone\web-inf\classes\zone\db\taglib

//QueryTagHandler.java
package zone.db.taglib;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.jsp.*;
import javax.servlet.jsp.tagext.*;

public class QueryTagHandler extends BodyTagSupport {
	public Connection con = null;
public int doAfterBody() throws JspException {
	try {
		String query = getBodyContent().getString();
		System.out.println("[QueryTagHandler] doAfterBody, Query 
Body-> " + getBodyContent().getString());
		
		Statement stmt = getConnection().createStatement();
		
		ResultSet rs = stmt.executeQuery(query);

		this.pageContext.setAttribute(getId(), rs, 
pageContext.PAGE_SCOPE);
		
	} catch (Exception exc) {
		throw new JspException(exc.getMessage());
	}
	return SKIP_BODY;
}
public Connection getConnection() {
	return con;
}
public void setConnection(String newConnection) throws JspException{
	try {
		System.out.println("[QueryTagHandler] setConnection, 
Attribute-> " + newConnection);
		con = (Connection) pageContext.findAttribute
(newConnection);
		System.out.println("[QueryTagHandler] Connection : " + 
con);
		
	} catch (Exception exc) {
		throw new JspException(exc.getMessage());
	}
}
}


> Can u show me the content of QueryTagHandler.java and the absolute 
> directories which contains these class
> 
> -----Original Message-----
> From: "Brandon Ng" <nodnarb_33@y...>
> To: "Pro_JavaServer_Pages" <pro_jsp@p...>
> Date: Fri, 25 May 2001 07:29:33
> Subject: [pro_jsp] Why can't i compile this?
> 
> > hi
> > i have compile QueryTagHandler.java already.
> > but why can't i compile the following file? They are in the same
> > directory.
> > After i compile, an error was found which is the superclass is not
> > found.
> > 
> > 
> > package zone.db.taglib;
> > 
> > import java.sql.Connection;
> > import java.sql.ResultSet;
> > import java.sql.Statement;
> > 
> > import javax.servlet.jsp.*;
> > import javax.servlet.jsp.tagext.*;
> > 
> > public class ModifyTagHandler extends QueryTagHandler {
> > 	public Connection con = null;
> > public int doAfterBody() throws JspException {
> > 	try {
> > 		String modify = getBodyContent().getString();
> > 		System.out.println("[QueryTagHandler] doAfterBody, Query 
> > Body-> " + getBodyContent().getString());
> > 		
> > 		Statement stmt = getConnection().createStatement();
> > 		
> > 		int result = stmt.executeUpdate(modify);
> > 		getConnection().commit();
> > 		pageContext.setAttribute(getId(), new Integer(result), 
> > PageContext.PAGE_SCOPE);
> > 	} catch (Exception exc) {
> > 		throw new JspException(exc.getMessage());
> > 	}
> > 	return SKIP_BODY;
> > }
> > }
> >

  Return to Index