wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes problem in jsp:useBean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "problem in jsp:useBean" Watch "problem in jsp:useBean" New topic
Author

problem in jsp:useBean

Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
hi,
i am facing problem in pg 350 of HFSJ

i have a servlet (code is from HFSJ)
Serv1.java




i have a java bean class Person





i have a jsp page

<%@ page import="foo.Person" %>
<html>
<body>
<!-- Normal java script code
<% foo.Person p= (foo.Person) request.getAttribute("person"); %>
Person is: <%=p.getName()%>
<jsp:useBean id="person" class="foo.Person" scope="request"/>
Person created by servlet: <jsp:getProperty name="person" property="name" />-->
<jsp:useBean id="person" class="foo.Person" scope="page">
Person created by servlet: <jsp:setProperty name="person" property="name" value="Fred"/>

</jsp:useBean>
</body>
</html>


The error is surely with above part in bold ..the error which iam getting is

org.apache.jasper.JasperException: /result.jsp(9,0) useBean: Duplicate bean name: {0}
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:102)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:617)
org.apache.jasper.compiler.Node$UseBean.accept(Node.java:1160)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2393)
org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2399)
org.apache.jasper.compiler.Node$Root.accept(Node.java:489)
org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2343)
org.apache.jasper.compiler.Validator.validate(Validator.java:1737)
org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:165)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:294)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:281)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
Serv1.doGet(Serv1.java:13)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)


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


--------------------------------------------------------------------------------

Apache Tomcat/6.0.16

[ October 04, 2008: Message edited by: Maan Shenoy ]

Man Suraj
Someone says "Impossible is nothing". The man next him says "Let me see you licking your elbow tip!"
Matteo Palmieri
Greenhorn

Joined: Sep 09, 2008
Posts: 28
Hi,

the error you get at JSP compilation time is due to the duplicate
use of the jsp:useBean. In order to properly comment the first
jsp:useBean tag you should use the JSP comment <%-- --%>, not the
HTML comment <!-- -->

Matteo


SCJP1.4: 96% SCWCD5: 91%
Maan Suraj
Ranch Hand

Joined: Dec 20, 2007
Posts: 299
thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: problem in jsp:useBean