• Post Reply Bookmark Topic Watch Topic
  • New Topic

getproperty in jsp

 
ahmad tamimi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
new to JSP world, i'm trying to do some examples in using beans:
the servlet code is:



InputBean class is :



in the .jsp i'm tring to print out the value of bean(i expect to print jack on the screen)

but nothing is printed out, so what is the problem?
can i set the bean in the servlet and get it in the jsp or not?
Thank You




 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The modern way to do it would be with the EL:

${input.name}
 
ahmad tamimi
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:The modern way to do it would be with the EL:

${input.name}

Thank You For Your Replay
i try to do it as you mentioned above and it worked
but i still need to know why it is not print anything when i used <jsp:getproperty......
thank you
>
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I could not tell you as it's been over ten years since I used something like <getProperty>.
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason you are not seeing anything is because anything within the body of useBean tag only runs if the specified bean does not already exist. Since the bean exists in the request scope, it does not process the body.

Try the following if you are required to use the tag


There is no reason to use this since EL (Expression Language) is much easier to use. To get a reference to the bean use
${applicationScope.input} and to get the property ${applicationScope.input.name}.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65519
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mike Zal wrote:
${applicationScope.input} and to get the property ${applicationScope.input.name}.

That won't work as the bean isn't in application scope, but in request scope.

${input.name} will find it in any scope, and ${requestScope.input.name} will limit the search to request scope.
 
Mike Zal
Ranch Hand
Posts: 144
Fedora Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
That won't work as the bean isn't in application scope, but in request scope.


You're right, sorry about that.

Michael Balton wrote:
I always mess up some minute detail

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!