hi,
i have a login servlet, which validates the username and from there i
created the connection for that user. the username and connection are
stored in the session. i got this ConnectionHolder class from Jason
Hunter's book.
userSession.putValue("userName", uName);
userSession.putValue("userName.connection", holder);
And in one of my jsp pages, I need to use this ConnectionHolder, what I
did was:
<%@page language="java" import="java.sql.*"%>
<%ConnectionHolder
holder=(ConnectionHolder)session.getValue("userName.connection");
if (holder != null)
Connection conProfile = holder.getConnection(); %>
It gives me this error, "rg.apache.jasper.JasperException: Unable to
compile class for JSPF:\Program
files\tomcat\work\localhost_8080%2Ftest\_0002fjsp_0002fprofile_0002ejspprofile_jsp_10.java:64:
Class jsp.ConnectionHolder
not found.
How do I go about in getting the ConnectionHolder to work in my JSP?
Thanks.
cedric
Below is the ConnectionHolder classs:
class ConnectionHolder implements HttpSessionBindingListener {
private Connection con = null;
public ConnectionHolder (Connection con) {
//save the connection
this.con = con;
try {
con.setAutoCommit (false); //transactions can extend between web
pages!
}
catch (SQLException e) {
//perform error handling
}
}
public Connection getConnection() {
return con;
}
public void valueBound (HttpSessionBindingEvent event){
//do nothing when added to a session
}
public void valueUnbound (HttpSessionBindingEvent event){
//roll back changes when removed from a session
// (or when the session expires)
try {
if (con!=null) {
con.rollback(); //abandon any uncommitted data
con.close();
}
}
catch (SQLException e){
//report it
}
}
}
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets