aspose file tools*
The moose likes Struts and the fly likes Getting Message from properties file in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Getting Message from properties file in servlet" Watch "Getting Message from properties file in servlet" New topic
Author

Getting Message from properties file in servlet

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 130
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


A$HI$H
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16250
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
zb cong
Ranch Hand

Joined: Jan 14, 2002
Posts: 416
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting Message from properties file in servlet