aspose file tools*
The moose likes Struts and the fly likes not able to load resource bundle ( Resource.properties file) in jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "not able to load resource bundle ( Resource.properties file) in jsp" Watch "not able to load resource bundle ( Resource.properties file) in jsp" New topic
Author

not able to load resource bundle ( Resource.properties file) in jsp

Bhupeshy Yadav
Greenhorn

Joined: Oct 08, 2012
Posts: 5
Getting following error:

"index.jsp"
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>

<bean:message key="label.hello"/>

</body>
</html>

"Encryption.properties"

label.hello=Hello

"struts-config.xml"

<?xml version="1.0" encoding="ISO-8859-1" ?>

<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">

<struts-config>
<!-- ========== Form Bean Definitions =================================== -->
<form-beans>

</form-beans>
<!-- ========== Global Exception Definitions ============================== -->


<!-- ========== Global Forward Definitions ============================== -->
<!--<global-forwards type="org.apache.struts.action.ActionForward">
<forward name="index" path="/login.page" />
</global-forwards>-->
<!-- ========== Action Mapping Definitions ============================== -->
<action-mappings>



</action-mappings>


<controller>
<set-property property="processorClass"
value="web.arch.common.CustomRequestProcessor" />
</controller>

<message-resources parameter="build.classes.config" key ="Encrypt"/>

</struts-config>


"Web.xml" :

<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>
Encrypt</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>


</web-app>



Error message :

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:346)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


root cause

java.lang.NullPointerException
org.apache.struts.taglib.TagUtils.retrieveMessageResources(TagUtils.java:1175)
org.apache.struts.taglib.TagUtils.message(TagUtils.java:1038)
org.apache.struts.taglib.bean.MessageTag.doStartTag(MessageTag.java:224)
org.apache.jsp.index_jsp._jspx_meth_bean_message_0(index_jsp.java:97)
org.apache.jsp.index_jsp._jspService(index_jsp.java:70)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:298)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)

Tarun Trehan
Ranch Hand

Joined: Mar 16, 2012
Posts: 49

What is the location of your respurces file.
If its under JavaSource , it will automatically get loaded.


Thanks,
Tarun Trehan (http://allzhere.in)
Bhupeshy Yadav
Greenhorn

Joined: Oct 08, 2012
Posts: 5
Encrypt
-src
-build-->classes-->config-->Encrypt.properties
-WebContent
-META-INF
-WEB_INF-->lib
G krishna kumar
Greenhorn

Joined: Oct 10, 2012
Posts: 14
place your properties file in the classes folder it will work fine.
Bhupeshy Yadav
Greenhorn

Joined: Oct 08, 2012
Posts: 5
it is already in classes-->config folder
Bhupeshy Yadav
Greenhorn

Joined: Oct 08, 2012
Posts: 5
i have placed it in build-->classes-->Encrypt.properties but still getting same error
Varun Selva
Ranch Hand

Joined: Jun 17, 2012
Posts: 44

you put the Encrypt.properties file directly inside the WEB-INF/classes/ folder and set the struts-config.xml like
<message-resources parameter="Encrypt" />

Then it'll be fine


Varun Selva
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: not able to load resource bundle ( Resource.properties file) in jsp