• Post Reply Bookmark Topic Watch Topic
  • New Topic

Simple Question about Bean  RSS feed

 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii i'am new in JSP and i have a little little question:
in my page i use:
<% if (found==true) out.write("Records Found"); %> and works fine!
but if i change the code to have more generality:
<% if (found==true) out.write("<bean:message key=\"records.not.found\"/> ; %>
the result is that the JSP in correctly compiled but the results in NOTHING!!
What is the Problem?
Thanks in advance
Gabry
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a "View Source" on the resulting HTML and look at what appeared at the point you expected the output. Does that tell you what the problem is?
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiiii
in the source i have:
<bean:message key="records.not.found"/>
but none is displayed!
Gab
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly, the tag did not get translated (and since it is not valid HTML, nothing is displayed).
Tag translation happens long before the page is executed, so outputting custom tags like you tried to do cannot work.
Question: why are you using out.write() in the first place, rather than template text? If your tag was part of template text, you would be having no such problems.
[ May 06, 2004: Message edited by: Bear Bibeault ]
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thnaks Bear
Can you write the example code please?
Thank!!!
Gabriele
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you will learn more by doing it yourself. Take a stab at re-writing your original example without using out.write().
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks i Try!!
Gabriele
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any progress?
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear..
None!!!
I will find in the parameter of the bean:message tag?
Gabry
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hii i suppose logic:equal with the bean:message in the body..
i try and i have non errors but none output because the variable that i use is a local variable and not a bean property
???
Gabriele
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, here's a clue. In your original message you gave an example:

written without using out.write(), which is a very poor practice that you should avoid, this example would be:

Does that help?
 
gabriele rigamonti
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear THANKS for the code!
works fine
Gabry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!