File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Getting Message from properties file in servlet

ashish kulkarni
Ranch Hand

Joined: Aug 15, 2002
Posts: 131
If i have to get messages from properties file and
display them in jsp i use <bean:message
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

Joined: Jun 25, 2001
Posts: 17410

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.

An IDE is no substitute for an Intelligent Developer.
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:
subject: Getting Message from properties file in servlet
It's not a secret anymore!