Posted By:
star_mahmood
Posted On:
Sunday, December 30, 2007 04:07 AM
helo all i am working with JSP and EJBs. i have written a simple code for verifying username and password of user by using session beans. my problem is that i am getting the following exception: [EXCEPTION] type Exception report message description The server encountered an internal error () that prevented it from fulfilling this request. exception javax.servlet.ServletException: VerifyUser not bound org.apache.jasper.runtime.PageContextImpl.doHandle PageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:781)
More>>
helo all
i am working with JSP and EJBs. i have written a simple code for verifying username and password of user by using session beans. my problem is that i am getting the following exception:
[EXCEPTION]
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: VerifyUser not bound
org.apache.jasper.runtime.PageContextImpl.doHandle
PageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePa geException(PageContextImpl.java:781)
org.apache.jsp.Verify_jsp._jspService(org.apache.j sp.Verify_jsp:98)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)
root cause
javax.naming.NameNotFoundException: VerifyUser not bound
org.jnp.server.NamingServer.getBinding(NamingServe r.java:491)
org.jnp.server.NamingServer.getBinding(NamingServe r.java:499)
org.jnp.server.NamingServer.getObject(NamingServer .java:505)
org.jnp.server.NamingServer.lookup(NamingServer.ja va:278)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:610)
org.jnp.interfaces.NamingContext.lookup(NamingCont ext.java:572)
javax.naming.InitialContext.lookup(InitialContext. java:347)
org.apache.jsp.Verify_jsp._jspService(org.apache.j sp.Verify_jsp:67)
org.apache.jasper.runtime.HttpJspBase.service(Http JspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet .java:810)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doF ilter(ReplyHeaderFilter.java:81)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
----------------------------------------------------------
Apache Tomcat/5.5.9
[/EXCEPTION]
im also presenting code for ur consideration
Code: ( text )
VerifyUser.java
package hina.mahmood;
import javax.ejb.*;
import java.rmi.*;
public interface VerifyUser extends javax.ejb.EJBObject
{
public Boolean Verify(String user, String pswd) throws RemoteException;
}// end interface
---------------------------------------
VerifyUserHome.java
--------------------
package hina.mahmood;
import javax.ejb.*;
import java.rmi.*;
import javax.ejb.EJBHome;
public interface VerifyUserHome extends javax.ejb.EJBHome
{
public VerifyUser create() throws RemoteException,CreateException;
}// end interface
-------------------
VerifyUserBean.java
-----------------------
package hina.mahmood;
import javax.ejb.*;
import java.rmi.*;
import java.sql.*;
public class VerifyUserBean implements SessionBean
{
private SessionContext ctx;
public Boolean Verify(String user,String pswd) throws RemoteException
{
int flag=0;
Boolean bool=new Boolean("false");
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:honie");
Statement stmt=con.createStatement();
String query="Select username,password from hina";
ResultSet rs=stmt.executeQuery(query);
while(rs.next())
{
if((rs.getString("username").equals(user))&&(rs.getString("password").equals(pswd)))
{
flag=1;
break;
}
}// end while
}// end try
catch(Exception e)
{System.out.println(e);}
if(flag==0)
{
bool=new Boolean("false");
return bool;
}
else
if(flag==1)
{
bool=new Boolean("true");
return bool;
}
return bool;
}// end method
public void ejbcreate() throws RemoteException,CreateException
{}// end method
public void setSessionContext(SessionContext ctx)
{
this.ctx=ctx;
}
public void ejbPassivate()
{}
public void ejbActivate()
{}
public void ejbRemove()
{}
}// end class
---------------------
[note]
Verify.jsp is the page that uses the session bean
[/note]
-------------
<%@ page import="java.rmi.*,javax.naming.Context,javax.naming.Initi alContext,hina.mahmood.*"%>
<%
String username=request.getParameter("user");
String password=request.getParameter("pswd");
InitialContext cxt=new InitialContext();
Object obj=cxt.lookup("VerifyUser");
VerifyUserHome userHome=(VerifyUserHome)javax.rmi.PortableRemoteObject.narrow(obj,VerifyUserHome.class);
VerifyUser vs=userHome.create();
Boolean b=vs.Verify(username,password);
boolean bool=b.booleanValue();
if(bool)
response.sendRedirect("main.jsp");
else
response.sendRedirect("error.jsp");
%>
--------------
can anyone plz tel me that what this exception is and how can i get rid of it???
thanks
<<Less