File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes jsp useBean tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp useBean tag" Watch "jsp useBean tag" New topic

jsp useBean tag

seetarama raju
Ranch Hand

Joined: Feb 07, 2001
Posts: 104
iam having a problem with jsp useBean tag.
is the synax <jsp:useBean.. >
or just <jsp:useBean.... />
i mean which is the correct way of closing
and also is it compulsory to put all set and get propery tags
between the opening and closing useBean tags.
recently when iam trying with jrun it gave me an error when iam
trying to instantiate a bean class through this tag. i've kept the jsp file in the default web application directory and the class file in web-inf/clases folder.
the following is the error iam getting
500 Internal Server Error
javax.servlet.ServletException: Compilation error occured:
Found 1 errors in JSP file:
C:\\Program Files\\Allaire\\JRun\\servers\\default\\default-app\\hellouser.jsp:49: Syntax: ";" inserted to complete LocalVariableDeclarationStatement
Errors reported by compiler:C:/Program Files/Allaire/JRun/servers/default/default-app/WEB-INF/jsp/ Syntax: ";" inserted to complete LocalVariableDeclarationStatement
at allaire.jrun.scripting.JavaCompilerService.compile(../scripting/
at allaire.jrun.jsp.JSPServlet.compilePage(../jsp/
at allaire.jrun.jsp.JSPServlet.createServlet(../jsp/
at allaire.jrun.jsp.JSPServlet.loadPage(../jsp/
at allaire.jrun.jsp.JSPServlet.service(../jsp/
at allaire.jrun.servlet.JRunSE.service(../servlet/
at allaire.jrun.servlet.JRunSE.runServlet(../servlet/
at allaire.jrun.servlet.JRunRequestDispatcher.forward(../servlet/
at allaire.jrun.servlet.JRunSE.service(../servlet/
at allaire.jrun.servlet.JvmContext.dispatch(../servlet/
can somebody tell me where is the problem

Brett B Doehr

Joined: Jun 04, 2001
Posts: 11
Either syntax should work. The syntax I normally use is:
<jsp:useBean class="FooBean" id="foo" scope="session">
However, the other syntax will also work:
<jsp:useBean class="FooBean" id="foo" scope="session" />
As far as the set and get property tags, put them between
the useBean tags if you want them to execute only when the
bean is first instantiated. If the bean is reused, either
on that page or another one, any set or get property tags
will be ignored. For good general info on useBean, go to:
It's hard to be sure what's causing your error without seeing
the line of code it referenced. My guess it that you have a
declaration statement without a semi-colon at the end:
<%! int i=0 %> instead of <%! int i=0; %>
I agree. Here's the link:
subject: jsp useBean tag
jQuery in Action, 3rd edition