473,378 Members | 1,594 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Java bean in JSP

17
HTML PAGE
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form action="second.jsp" method="get">
  4. YOur name <input type=text name="name">
  5. <input type=submit > 
  6. </form>
  7. </body>
  8. </html>
  9.  
// taking input from this and passing it to second.jsp
Expand|Select|Wrap|Line Numbers
  1. <jsp:useBean id="user" class="user.userclass" scope="session"/> 
  2. <jsp:setProperty name="user" property="name"/>             //setting name 
  3. <html>
  4. <body>
  5. <a href="third.jsp"> continue </a> 
  6. </body>
  7. </html>
  8.  
// seting name into bean file "userclass"


//getting name from bean file "userclass"
Expand|Select|Wrap|Line Numbers
  1. <jsp:userBean id="user" class="user.userclass" scope="session"/>
  2. <html>
  3. <body>
  4. <h1> your details 
  5. your name:<%= user.getUsername() %>
  6. </body>
  7. </html>
  8.  


when i run the above program , it is unable to find bean file ,

error is :
org.apache.jasper.JasperException: /second.jsp(2,0) The value for the useBean class attribute user.userclass is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jsp Error(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatc h(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspErro r(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisit or.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Nod e.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody( Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node .java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.j ava:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Generator.generate(Gene rator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:470)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:451)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


am i missing something , i want to know where to place .class file(bean file)
Feb 11 '08 #1
1 2653
HTML PAGE
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <body>
  3. <form action="second.jsp" method="get">
  4. YOur name <input type=text name="name">
  5. <input type=submit > 
  6. </form>
  7. </body>
  8. </html>
  9.  
// taking input from this and passing it to second.jsp
Expand|Select|Wrap|Line Numbers
  1. <jsp:useBean id="user" class="user.userclass" scope="session"/> 
  2. <jsp:setProperty name="user" property="name"/>             //setting name 
  3. <html>
  4. <body>
  5. <a href="third.jsp"> continue </a> 
  6. </body>
  7. </html>
  8.  
// seting name into bean file "userclass"


//getting name from bean file "userclass"
Expand|Select|Wrap|Line Numbers
  1. <jsp:userBean id="user" class="user.userclass" scope="session"/>
  2. <html>
  3. <body>
  4. <h1> your details 
  5. your name:<%= user.getUsername() %>
  6. </body>
  7. </html>
  8.  


when i run the above program , it is unable to find bean file ,

error is :
org.apache.jasper.JasperException: /second.jsp(2,0) The value for the useBean class attribute user.userclass is invalid.
org.apache.jasper.compiler.DefaultErrorHandler.jsp Error(DefaultErrorHandler.java:39)
org.apache.jasper.compiler.ErrorDispatcher.dispatc h(ErrorDispatcher.java:409)
org.apache.jasper.compiler.ErrorDispatcher.jspErro r(ErrorDispatcher.java:150)
org.apache.jasper.compiler.Generator$GenerateVisit or.visit(Generator.java:1227)
org.apache.jasper.compiler.Node$UseBean.accept(Nod e.java:1116)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Node$Visitor.visitBody( Node.java:2213)
org.apache.jasper.compiler.Node$Visitor.visit(Node .java:2219)
org.apache.jasper.compiler.Node$Root.accept(Node.j ava:456)
org.apache.jasper.compiler.Node$Nodes.visit(Node.j ava:2163)
org.apache.jasper.compiler.Generator.generate(Gene rator.java:3272)
org.apache.jasper.compiler.Compiler.generateJava(C ompiler.java:244)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:470)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:451)
org.apache.jasper.compiler.Compiler.compile(Compil er.java:439)
org.apache.jasper.JspCompilationContext.compile(Js pCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.servic e(JspServletWrapper.java:295)
org.apache.jasper.servlet.JspServlet.serviceJspFil e(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspSe rvlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet .java:802)


am i missing something , i want to know where to place .class file(bean file)
is your class file in the same package or in a different location?????

If the <jsp:use-Bean> action cannot find an existing bean in the specified scope, it creates a new instance of the bean’s class as specified by the value of the class attribute using the class’s publicly defined no-argument constructor. Therefore, the class specified by the class attribute must be a public non-abstract class and must have a public no-argument
constructor. If the class is part of a package, then the fully qualified class
name must be specified as mypackage.MyClass.
Feb 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: GeRmIc | last post by:
Hello Friends, I am working on a project where the service provider is written in JAVA and the client is written in .NET (C#). The Server communicates with the client through Java Beans. (1)...
0
by: donnet | last post by:
To those familiar with Java beans, question on how to do with ASP.NET: I come from J2EE and starting to learn ASP.NET and C#. I want to find a way to display a web form filled with data taken...
2
by: Paul in Toronto | last post by:
First off, this is for a school assignment... I know some people get squeamish about this sort of post, but I'm kind of up a creek. Basically, as part of a semester-long project, we need to add...
458
by: wellstone9912 | last post by:
Java programmers seem to always be whining about how confusing and overly complex C++ appears to them. I would like to introduce an explanation for this. Is it possible that Java programmers...
1
by: prasath03 | last post by:
I'm new to JSP, and am trying this sample code for instantiating a bean for use in a disconnected ResultSet, i placed the rowset.jar under WEB-INF/lib directory but i get the following error: ...
0
by: qpmzlaks | last post by:
Hello, I was trying to get connected to DB2 from java using a Atomikos datasource. This is the config for the same; <bean id="dataSourceAtom1" class="com.atomikos.jdbc.SimpleDataSourceBean"...
2
by: zoeabraham | last post by:
I am Using STRUTS1.4 in NetBeans5.5 IDE Here we have a JSP Page <%@page contentType="text/html"%> <%@page pageEncoding="UTF-8"%> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"...
1
by: ksrashmi | last post by:
HI I am getting following exception when i use mxml tags in jsp <%@ taglib uri="FlexTagLib" prefix="mm" %> can any one tell why i am getting this exception type Exception report message...
2
by: ramprakashjava | last post by:
This is index.jsp page code: <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %> <%@ taglib...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.