struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davargas123 <>
Subject Losing ActionForm Data on submit
Date Thu, 03 Dec 2009 15:20:42 GMT

So, I have an issue where when I submit a form, instead of the corresponding
ActionForm being populated with the correct field data, it remains
unpopulated for a reason unknown to me. Here is the form on my JSP page(js
functions provided for clarity, very simple):

function encryptSSN(){

function showError(){

function validateSSN(){
	var ssn = document.ssnLookupForm.ssn.value;
    if( /^\d{3}-\d{2}-\d{4}$/.test(ssn) == false ){
<html:form method="post" action="/SSNLookupEncrypt">
	<div style="text-align: center; font-family: arial;">
      <div class="productsdiv" style="margin: 0 auto; padding: 5px;
text-align: left; width: 43%">
            SSN: <input type="text" name="ssn"
            <div class="spacer">&nbsp;</div>
            Format: XXX-XX-XXXX
         <div class="spacer">&nbsp;</div>
         <div style="text-align: center;">
           <input type="button" value="Encrypt" onclick="validateSSN()"/>
         <div class="textBox" id="box1" style="text-align: center;
         <div class="spacer">&nbsp;</div>
           Encrypted Value: <%=ssnLookupForm.getEncryptedSSN()%>
      <div class="spacer">&nbsp;</div>
This is the corresponding ActionForm:

public class SSNLookupForm extends ActionForm{

	private static Logger log =
	private String ssn = "XXX-XX-XXXX";
	private String encryptedSSN = "[Encrypted Value]";
	public String getSSN(){
		return ssn;
	public void setSSN(String ssn){
		this.ssn = ssn;
	public String getEncryptedSSN(){
		return encryptedSSN;
	public void setEncryptedSSN(String encryptedSSN){
		this.encryptedSSN = encryptedSSN;
	public void reset(ActionMapping mapping, HttpServletRequest request) {
	    this.ssn = "XXX-XX-XXXX";
	    this.encryptedSSN= "[Encrypted Value]";


What should happen is that the user enters the SSN in xxx-xx-xxxx format
into the box, and clicks the Encrypt button(the javascript validation works
fine, I've tested it). Then, the form should get populated with the data so
that the Action class can do the background work, and display the page with
the SSN that was input and the value that was created from the encryption. 
I can't figure out why the data isn't being submitted. I tried using the
Struts library tags like <html:text> and <html:button> and whatnot, but for
some reason the elements wouldn't display on the page when I would use them,
so I just reverted to the regular HTML counterparts. 
The problem is with the form being populated with the data, because I hard
coded in a value for the SSN in my action class and the encryption happened
perfectly fine and the page showed up as it should have, but I can't get
user input data to make it to the form, and I'm totally at a loss. Any help
would be greatly appreciated. Keep in mind this is the first time I've ever
had to use anything like Struts.
View this message in context:
Sent from the Struts - User mailing list archive at

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message