• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Using <jsp:useBean> without specifying type and class attribute

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the servlet class setting request parameter


This is the JavaBean class



And This is the jsp page which access request parameter set by servlet


When I hit the servlet it gives error jsp.error.usebean.missingType.

And when I put type attribute with useBean tag it works.
But I read in book and it says that If you have set the attribute and then try to get it in jsp .You can left specifying type and class attribute.
But in case if you haven`t set the attribute then you must specify class attribute.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using useBean at all? Once the scoped variable has been set into request scope, it is available through the JSTL and EL. The useBean tag is no longer necessary.

 
Anindya Roy
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you have to do something like

 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing this because Its on exam.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which exam?
 
Mahtab Alam
Ranch Hand
Posts: 391
1
Java MySQL Database PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oracle Java EE Web Component Developer
 
Viktor Pergjoka
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The syntax of the jsp use bean is as follows:

<jsp:useBean id="name" scope="page|request|session|application" typeSpec />

typeSpec ::=
class="className" |
class="className" type="typeName" |
type="typeName" class="className" |
beanName="beanName" type="typeName" |
type="typeName" beanName="beanName" |
type="typeName"


So you used a wrong syntax.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic