Win a copy of Java EE 8 High Performance this week in the Java/Jakarta EE forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp useBean tag  RSS feed

Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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; %>
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!