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
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.
posted 14 years ago
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.
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads