You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ram001 <sm...@yahoo.com> on 2006/10/16 19:34:48 UTC

Hepl need with properties file in Struts

Hi 

In my Struts application the problem is like below 

javax.servlet.ServletException: Missing message for key
"userRegistration.firstName" in bundle "(default bundle)" for locale en_US

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:682)

org.apache.jsp.userRegistration_jsp._jspService(userRegistration_jsp.java:99)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
	org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

There  id no method like firstName in my Action form java class . i got
FirstName Getter method in Action form
The code is like  this 
UserRegistrationForm .java 

package strutsTutorial;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import javax.servlet.http.HttpServletRequest;
public class UserRegistrationForm extends ActionForm {
private String firstName;
private String lastName;
private String userName;
private String password;
private String passwordCheck;
private String email;
private String phone;
private String fax;
private boolean registered;
public String getEmail() {
return email;
}
public void setEmail(String string) {
email = string;
}
public String getFirstname() {
return firstName;
}
public void setFirstname(String string) {
firstName = string;
}
public String getLastname() {
return lastName;
}
public void setLastname(String string) {
lastName = string;
}
public String getUsername() {
return userName;
}
public void setUsername(String string) {
userName = string;
}
public String getPassword() {
return password;
}
public void setPassword(String string) {
password = string;
}
public String getPasswordcheck() {
return passwordCheck;
}
public void setPasswordcheck(String string) {
passwordCheck = string;
}
public String getPhone() {
return phone;
}
public void setPhone(String string) {
phone = string;
}
public String getFax() {
return fax;
}
public void setFax(String string) {
fax = string;
}
public boolean getRegistered() {
return registered;
}
public void setRegistered(boolean string) {
registered = string;
}
public void reset(ActionMapping mapping,
HttpServletRequest request) {
firstName=null;
lastName=null;
userName=null;
password=null;
passwordCheck=null;
email=null;
phone=null;
fax=null;
registered=false;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request) {
ActionErrors errors = new ActionErrors();
if (firstName==null|| firstName.trim().equals("")){
errors.add("Firstname",new
ActionError("userRegistration.Firstname.problem"));
}
return errors;
}
}


Properties file

userRegistration.Firstname=First Name
userRegistration.Lastname=Last Name
userRegistration.Username=User Name
userRegistration.Password=PassWord
userRegistration.Email=email
userRegistration.Phone=phone
userRegistration.Fax=fax
userRegistration.Firstname.problem=The first name was blank


i place this resource properties file in web.xml and struts-config.xml. can
any one hel me 

Thanks in advance  
-- 
View this message in context: http://www.nabble.com/Hepl-need-with-properties-file-in-Struts-tf2453889.html#a6839218
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Hepl need with properties file in Struts

Posted by Li <am...@gmail.com>.
It says that you missed key"userRegistration.firstName", but in your
propertiy file, there is no such key ... :)

On 10/17/06, ram001 <sm...@yahoo.com> wrote:
>
>
> Hi
>
> In my Struts application the problem is like below
>
> javax.servlet.ServletException: Missing message for key
> "userRegistration.firstName" in bundle "(default bundle)" for locale en_US
>
> org.apache.jasper.runtime.PageContextImpl.handlePageException(
> PageContextImpl.java:682)
>
> org.apache.jsp.userRegistration_jsp._jspService
> (userRegistration_jsp.java:99)
>         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java
> :136)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java
> :320)
>         org.apache.jasper.servlet.JspServlet.serviceJspFile(
> JspServlet.java:294)
>         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
>         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
>
> There  id no method like firstName in my Action form java class . i got
> FirstName Getter method in Action form
> The code is like  this
> UserRegistrationForm .java
>
> package strutsTutorial;
> import org.apache.struts.action.ActionForm;
> import org.apache.struts.action.ActionMapping;
> import org.apache.struts.action.ActionErrors;
> import org.apache.struts.action.ActionError;
> import javax.servlet.http.HttpServletRequest;
> public class UserRegistrationForm extends ActionForm {
> private String firstName;
> private String lastName;
> private String userName;
> private String password;
> private String passwordCheck;
> private String email;
> private String phone;
> private String fax;
> private boolean registered;
> public String getEmail() {
> return email;
> }
> public void setEmail(String string) {
> email = string;
> }
> public String getFirstname() {
> return firstName;
> }
> public void setFirstname(String string) {
> firstName = string;
> }
> public String getLastname() {
> return lastName;
> }
> public void setLastname(String string) {
> lastName = string;
> }
> public String getUsername() {
> return userName;
> }
> public void setUsername(String string) {
> userName = string;
> }
> public String getPassword() {
> return password;
> }
> public void setPassword(String string) {
> password = string;
> }
> public String getPasswordcheck() {
> return passwordCheck;
> }
> public void setPasswordcheck(String string) {
> passwordCheck = string;
> }
> public String getPhone() {
> return phone;
> }
> public void setPhone(String string) {
> phone = string;
> }
> public String getFax() {
> return fax;
> }
> public void setFax(String string) {
> fax = string;
> }
> public boolean getRegistered() {
> return registered;
> }
> public void setRegistered(boolean string) {
> registered = string;
> }
> public void reset(ActionMapping mapping,
> HttpServletRequest request) {
> firstName=null;
> lastName=null;
> userName=null;
> password=null;
> passwordCheck=null;
> email=null;
> phone=null;
> fax=null;
> registered=false;
> }
> public ActionErrors validate(ActionMapping mapping,HttpServletRequest
> request) {
> ActionErrors errors = new ActionErrors();
> if (firstName==null|| firstName.trim().equals("")){
> errors.add("Firstname",new
> ActionError("userRegistration.Firstname.problem"));
> }
> return errors;
> }
> }
>
>
> Properties file
>
> userRegistration.Firstname=First Name
> userRegistration.Lastname=Last Name
> userRegistration.Username=User Name
> userRegistration.Password=PassWord
> userRegistration.Email=email
> userRegistration.Phone=phone
> userRegistration.Fax=fax
> userRegistration.Firstname.problem=The first name was blank
>
>
> i place this resource properties file in web.xml and struts-config.xml.
> can
> any one hel me
>
> Thanks in advance
> --
> View this message in context:
> http://www.nabble.com/Hepl-need-with-properties-file-in-Struts-tf2453889.html#a6839218
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
When we invent time, we invent death.

RE: Hepl need with properties file in Struts

Posted by Dongyi Liu <do...@googlemail.com>.
Hi there,

As you can see, you have defined the firstName field in your action class:

private String firstName;

but in your properties file, you defined it as:

userRegistration.Firstname=First Name

please check your userRegistration.jsp, be sure to use
userRegistration.Firstname when refer to the messages in the resource
boundle (you used userRegistration.firstName in your jsp page).

Dongyi


-----Original Message-----
From: ram001 [mailto:smilewithraghu@yahoo.com] 
Sent: 16 October 2006 18:35
To: user@struts.apache.org
Subject: Hepl need with properties file in Struts


Hi 

In my Struts application the problem is like below 

javax.servlet.ServletException: Missing message for key
"userRegistration.firstName" in bundle "(default bundle)" for locale en_US

org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
l.java:682)

org.apache.jsp.userRegistration_jsp._jspService(userRegistration_jsp.java:99
)
	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:3
20)
	
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:294)
	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

There  id no method like firstName in my Action form java class . i got
FirstName Getter method in Action form
The code is like  this 
UserRegistrationForm .java 

package strutsTutorial;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionError;
import javax.servlet.http.HttpServletRequest;
public class UserRegistrationForm extends ActionForm {
private String firstName;
private String lastName;
private String userName;
private String password;
private String passwordCheck;
private String email;
private String phone;
private String fax;
private boolean registered;
public String getEmail() {
return email;
}
public void setEmail(String string) {
email = string;
}
public String getFirstname() {
return firstName;
}
public void setFirstname(String string) {
firstName = string;
}
public String getLastname() {
return lastName;
}
public void setLastname(String string) {
lastName = string;
}
public String getUsername() {
return userName;
}
public void setUsername(String string) {
userName = string;
}
public String getPassword() {
return password;
}
public void setPassword(String string) {
password = string;
}
public String getPasswordcheck() {
return passwordCheck;
}
public void setPasswordcheck(String string) {
passwordCheck = string;
}
public String getPhone() {
return phone;
}
public void setPhone(String string) {
phone = string;
}
public String getFax() {
return fax;
}
public void setFax(String string) {
fax = string;
}
public boolean getRegistered() {
return registered;
}
public void setRegistered(boolean string) {
registered = string;
}
public void reset(ActionMapping mapping,
HttpServletRequest request) {
firstName=null;
lastName=null;
userName=null;
password=null;
passwordCheck=null;
email=null;
phone=null;
fax=null;
registered=false;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest
request) {
ActionErrors errors = new ActionErrors();
if (firstName==null|| firstName.trim().equals("")){
errors.add("Firstname",new
ActionError("userRegistration.Firstname.problem"));
}
return errors;
}
}


Properties file

userRegistration.Firstname=First Name
userRegistration.Lastname=Last Name
userRegistration.Username=User Name
userRegistration.Password=PassWord
userRegistration.Email=email
userRegistration.Phone=phone
userRegistration.Fax=fax
userRegistration.Firstname.problem=The first name was blank


i place this resource properties file in web.xml and struts-config.xml. can
any one hel me 

Thanks in advance  
-- 
View this message in context:
http://www.nabble.com/Hepl-need-with-properties-file-in-Struts-tf2453889.htm
l#a6839218
Sent from the Struts - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org