• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting Message from properties file in servlet

 
ashish kulkarni
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
If i have to get messages from properties file and
display them in jsp i use <bean:message
key="index.title"/>
tag to do so,
if i want to get this same message in my servlet how
can i do it, i want this message as String in servlet
 
Tim Holloway
Saloon Keeper
Posts: 18359
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a standard Java Resource file. If you'll notice, the path of your Application Resources file ("classname") is one of the parameters that gets passed into the Struts controller servlet. If all else fails, download the Struts source code and see how THEY do it, but I think it's not that complicated.
Cautionary note, however. The intent of Struts is that the Struts Servlet ALWAYS gets called in order to ensure central control and continuity. Think twice about plunking in a servlet that sidesteps that policy, or you may get burned someday. Consider either extending the standard Struts servlet (if you need control for every pass) or, if you have specialized needs, there's not really that much difference in the way a Struts Action perform() method works over the HttpServlet's own service() method.
 
zb cong
Ranch Hand
Posts: 416
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you can use "getResourceAsStream(String RelativePath)" to locate your properties files within the servlet,or use "getResource(.....)" method get the message from the properties file within the struts Action class.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic