jQuery in Action, 3rd edition
The moose likes JSP and the fly likes bean:message key and bean:write not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "bean:message key and bean:write not working" Watch "bean:message key and bean:write not working" New topic

bean:message key and bean:write not working

erika chua

Joined: Oct 03, 2011
Posts: 2
I have this string in my .java file.

String str = "<a href =\"" + url + "\"><bean:message key=\"label.search\"/></a>";

that turns out like this below, which is (i suppose) correct.

<a href = "searchUser.do?action=search"><bean:message key="label.search"/></a>

and it follows this

request.setAttribute("header", str);

In my .jsp file

<bean:write name="header" scope="request" filter="false"/>

In my properties file

label.search = Search

I dont understand why this does not work. but of course if i change <bean:message key="label.search"/> to a text like ABC, it works perfectly fine.
I also tried label.search in other .jsp files, it works fine too
olivier dutranoit
Ranch Hand

Joined: Aug 20, 2011
Posts: 81


You cannot write in your servlet

and next, using this string in your jsp, and expecting the syntax to be evaluated.

<bean:message key=\"label.search\"/>
can only be evaluated inside a jsp. Not trough your servlet.
I agree. Here's the link: http://aspose.com/file-tools
subject: bean:message key and bean:write not working
It's not a secret anymore!