aspose file tools*
The moose likes JSP and the fly likes jsp and javabeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp and javabeans" Watch "jsp and javabeans" New topic
Author

jsp and javabeans

arjita mahajan
Greenhorn

Joined: Nov 10, 2012
Posts: 11
i am trying to create a login page in which user will enter details and submit request to a jsp page... jsp page in turn enter details to database using java beans
here are my code


when i am compiling and running this i am getting the follwing errors
HTTP Status 500 -

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 3 in the jsp file: /Register.jsp
GameBean cannot be resolved to a type
1: <%@page language="java" import ="java.sql.*" errorPage="error.jsp" %>
2:
3: <jsp:useBean id="lg" scope="session" class="GameBean"/>
4:
5: <html>
6: <head>


An error occurred at line: 3 in the jsp file: /Register.jsp
GameBean cannot be resolved to a type
1: <%@page language="java" import ="java.sql.*" errorPage="error.jsp" %>
2:
3: <jsp:useBean id="lg" scope="session" class="GameBean"/>
4:
5: <html>
6: <head>


An error occurred at line: 3 in the jsp file: /Register.jsp
GameBean cannot be resolved to a type
1: <%@page language="java" import ="java.sql.*" errorPage="error.jsp" %>
2:
3: <jsp:useBean id="lg" scope="session" class="GameBean"/>
4:
5: <html>
6: <head>


Stacktrace:
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:102)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:331)
org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:457)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:378)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:353)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:340)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:644)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:358)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)

note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
Apache Tomcat/7.0.22

Please help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please read through the JspFaq. Beans must be placed in a package other than the default.

Also, placing Java code in a JSP is an obsolete and discredited poor practice. Please see this JspFaq entry.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
arjita mahajan
Greenhorn

Joined: Nov 10, 2012
Posts: 11
even if i place the bean in other package ..should the path of class be changed in:
<jsp:useBean id="lg" scope="session" class="GameBean"/>
i am not getting this in JspFaqs
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Yes, otherwise how would the tag know where to find the bean?
arjita mahajan
Greenhorn

Joined: Nov 10, 2012
Posts: 11
but how am i suppose to change this because following line is giving me error:
<jsp:useBean id="lg" scope="session" class="WebApplication1/build/web/WEB-INF/classes/newFolder/GameBean"/>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

You don't give the file path to the bean, you give it the beans fully-qualified class name.

From what you've posted, that would be "newFolder.GameBean".

However, "newFolder" is a poor choice for a package name. First of all, it's pretty meaningless. Second, it should be all lowercase by convention.
arjita mahajan
Greenhorn

Joined: Nov 10, 2012
Posts: 11
thanks a lot... it worked fine.. but now the data is not getting entered into the database ..can you please suggest me the solution of this, when i click the submit button of register.html it directs me to Register.jsp page but data is not updated in my database...please help
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61766
    
  67

Please start new topics for new questions. And be sure to TellTheDetails.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp and javabeans