Struts where are values stored between jsp pages?
Hi.I realize that this is forum is not specifically for struts but I thought someone might know the answer to my question.
I have run the following code. The code contains two JSPs that both get there values from the same ArrayList generated by the same actionform so contain the same data. Example.jsp is diplayed when the application is first run when submit is clicked newjsp.jsp is displayed.
If a value in the fields of example.jsp is changed and submit is clicked the altered value is also displayed in newjsp.jsp. I am confused by this as after submit is clicked ExampleForm.java method reset is called which returns the variable values to their original value but the newly entered value is still displayed. Please tell me how this works
Example.jsp
<%@ page language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested"%>
<html>
<head>
<title>JSP for exampleForm form</title>
</head>
<body>
<html:form action="/example">
<h3>Use of nested:iteration tag</h3>
<nested:nest property="department">
DEP. ID: <nested:text property="id"/> <br />
NAME: <nested:text property="name"/> <br /><br />
<nested:iterate property="customers">
<b>Customer info</b><br />
CUST. ID: <nested:text property="id"/> <br />
NAME: <nested:text property="name"/> <br />
</nested:iterate>
</nested:nest>
<br />
<br />
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
Newjsp.jsp
<%@ page language="java"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-nested" prefix="nested"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<html>
<head>
<title>JSP for exampleForm form</title>
</head>
<body>
<html:form action="/example">
<h3>Use of nested:iteration tag</h3>
<nested:nest property="department">
<table>
<nested:iterate property="customers">
<tr><td>Customer info</td>
<td>CUST. ID: <nested:text property="id"/> </td>
<td>NAME: <nested:text property="name"/> </td>
</nested:iterate>
</tr>
</table>
</nested:nest>
<br />
<br />
<html:submit/><html:cancel/>
</html:form>
</body>
</html>
ExampleAction.jsp
package de.laliluna.tutorial.nested.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import de.laliluna.tutorial.nested.form.ExampleForm;
import de.laliluna.tutorial.nested.object.*;
import java.util.*;
public class ExampleAction extends org.apache.struts.action.Action {
/* forward name="success" path="" */
private static final String SUCCESS = "success";
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
ExampleForm formBean = (ExampleForm) form;
Department depart = formBean.getDepartment();
ArrayList dep = (ArrayList) depart.getCustomers();
Customer cust0 = (Customer) dep.get(0);
System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust0.getName());
System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust0.getId());
Customer cust1 = (Customer) dep.get(1);
System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust1.getName());
System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust1.getId());
Customer cust2 = (Customer) dep.get(2);
System.out.println(">>>>>>>>>>>>>> customer.getName() = " + cust2.getName());
System.out.println(">>>>>>>>>>>>>> customer.getId() = " + cust2.getId());
return mapping.findForward("example");
ExampleForm.jsp
package de.laliluna.tutorial.nested.form;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import de.laliluna.tutorial.nested.object.*;
import java.util.ArrayList;
import java.util.Collection;
public class ExampleForm extends org.apache.struts.action.ActionForm {
Department department;
public Department getDepartment() {
return department;
public void setDepartment(Department department) {
this.department = department;
public void reset(ActionMapping mapping,
HttpServletRequest request) {
System.out.println("Entered action bean reset");
Collection customers = new ArrayList();
customers.add(new Customer(1, "Maria"));
customers.add(new Customer(2, "Klaus"));
customers.add(new Customer(3, "Peter"));
department = new Department(1, "Department A", customers);
Customer.java
package de.laliluna.tutorial.nested.object;
public class Customer {
private int id;
private String name;
public Customer() {
public Customer(int id, String name) {
this.id = id;
this.name = name;
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
Department.java
package de.laliluna.tutorial.nested.object;
import java.util.Collection;
public class Department {
private int id;
private String name;
private Collection customers;
public Department() {
public Department(int id, String name, Collection customers) {
this.id = id;
this.name = name;
this.customers = customers;
public Collection getCustomers() {
return customers;
public void setCustomers(Collection customers) {
this.customers = customers;
public int getId() {
return id;
public void setId(int id) {
this.id = id;
public String getName() {
return name;
public void setName(String name) {
this.name = name;
}
Thanks for responding.
I set the debugger as you suggested and found that method reset is being called.
I did not write the whole of this program I was just playing around with and expanding a struts example I found on line.
http://www.laliluna.de/articles/struts-nested-iteration-tutorial.html
It contains the reset method.
I am interested to know how to reset the values. So am clearing the data after it has been submitted, just to reset. I assumed that once the new page was arrived at the values would be taken from the array.
I am quite new to struts and am not familiar with example_input.action and example.action I will look into these.
Similar Messages
-
To pass value between jsp page
How can I pass hidden's value from a jsp page to other?
My code is:
a.jsp
<h:form id="insUser">
<h:inputHidden id="flag" value="1"></h:inputHidden>
</h:form>
b.jsp
<%String flag="";
flag=request.getParameter("flag");
out.print("flag="+flag);
%>
b.jsp shows: flag=null
Could you help me?Because this hidden field id is insUser:flag, but not just flag.
If you have subview or other naming container(s) around form, the id name might be even longer.
Sergey : https://ajax4jsf.dev.java.net/ -
Struts can't display the input jsp page
Hello,
I'm using Struts 1.3.8 to construct a simple user registration system, in which the user could input his info (such as uuname and gpin, both are strings) in a jsp page, and after the submit, the system should go to a success page. However, somehow, when I access the url, it goes directly to the success page, but not stay at the input page.
Here is my {color:#ff0000}struts-xml.config{color}
bq. <?xml version="1.0" encoding="UTF-8"?> \\ <!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.3//EN" "http://struts.apache.org/dtds/struts-config_1_3.dtd"> \\ <struts-config> \\ <form-beans> \\ <form-bean name="{color:#ff0000}anotherUserForm{color}" type="com.visualbuilder.struts.beans.AnotherUser" /> \\ </form-beans> \\ <!-- Global Exceptions --> \\ <global-exceptions></global-exceptions> \\ <!-- Global Forwards --> \\ <global-forwards> \\ <forward name="success" path="success.jsp"/> </global-forwards> \\ <!-- Action Mappings --> \\ <action-mappings> \\ <action path="/{color:#ff0000}addanotheruser{color}" type="com.visualbuilder.struts.action.AddAnotherUserAction" name="{color:#ff0000}anotherUserForm{color}" attribute="user" input="{color:#ff0000}/addanotheruser.jsp{color}" cancellable="true"> \\ </action> \\ </action-mappings> \\ <!-- Message Resources --> \\ <message-resources \\ parameter="registration.resources.ApplicationResources" /> \\ </struts-config>
My action class is:
package com.visualbuilder.struts.action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.visualbuilder.struts.beans.AnotherUser;
public class AddAnotherUserAction extends Action {
@Override
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
if (isCancelled(request)) {
return mapping.findForward("welcome");
{color:#ff0000}AnotherUser anotherUser = (AnotherUser) form;{color}
System.out.println("UUName: " + anotherUser.getUuname() + "\tGPIN: " + anotherUser.getGpin());
{color:#ff0000}return mapping.findForward("success");{color}
My ActionForm class is:
package com.visualbuilder.struts.beans;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
public class AnotherUser extends ActionForm {
private static final long serialVersionUID = 1058901817587421984L;
private String uuname;
private String gpin;
public String getGpin() {
return gpin;
public void setGpin(String gpin) {
this.gpin = gpin;
public String getUuname() {
return uuname;
public void setUuname(String uuname) {
this.uuname = uuname;
@Override
public void reset(ActionMapping mapping, HttpServletRequest request) {
uuname = null;
gpin = null;
@Override
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
return errors;
The input jsp page is addanotheruser.jsp:
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ 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">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Another User Registration</title>
</head>
<body>
<h1>Another User Registration</h1>
<html:errors />
<table>
{color:#ff0000}<html:form action="addanotheruser">{color}
<tr>
<td>UUName</td>
<td>{color:#ff0000}<html:text property="uuname"></html:text>{color}*</td>
</tr>
<tr>
<td>GPIN</td>
<td>{color:#ff0000}<html:text property="gpin"></html:text>{color}*</td>
</tr>
<tr>
<td><html:submit/></td>
<td><html:cancel/></td>
</tr>
</html:form>
</table>
</body>
</html>
Everytime I access http://localhost:9080/addanotheruser.do, it jumps to the success.jsp, but not stay at addanotheruser.jsp to wait for the user input, and in the server's console, I could see the output "UUName: null GPIN: null"
I've been stuck at this simple program for three days, could anybody help to find the errors? Thanks a lot.sorry, the post looks ugly. Does anybody know how to make the indent not disappear?
-
Purchase Order ME23n - communication tab - where these values stored
Dear all
Can someone tell me where the
Purchase Order ME23n - communication tab - where these values stored
I am not able to find it.
Regards,
VenkatTable EKKO. All fields in communication tab are available here
EKKO-IHREZ Your Reference
EKKO-VERKF Responsible Salesperson at Vendor's Office
EKKO-TELF1 Vendor's Telephone Number
EKKO-UNSEZ Our Reference -
Hi!,
I need a suggestion to this problem that i'm facing.I want to traverse between JSP pages which follow like a wizard.i.e,i click next to go to the next page & back to traverse back to the previous page.I have some text fields in the previous page that contain some info.When i click on Next it goes to the next page.when i click on Previous i want to be able to view the input contents in the previous page.I tried using < a href="">
but it blanks all the fields ....
Somebody help
Regards,
ChaitraUse theseus mvc framework. (http://sourceforge.net/projects/theseus-mvc). It will teach you to properly and cleanly right web sites the way they should be, where JSP pages server only as a "view", the action class (servlet hybrid so to speak) handles passing form data to logic, logic returns to action class that then populate the request that is passed on to the JSP page to make use, especially if you use a JavaBean or taglib.
-
Get Javascript Value in a JSP page
Let's say this is my javascript function in a html page
.<head>
<!-- Function getFields -->
function getFields(){
if (row >= 0){
for(var i=0; i<costForm.elements.length; i++){
if(costForm.elements.type == "text" || costForm.elements[i].type == "hidden"){
dynTableFields[i] = (costForm.elements[i].value)? costForm.elements[i].value : "";
if(costForm.elements[i].type == "select-one"){
dynTableFields[i] = costForm.elements[i].selectedIndex;
</head>
How do i get the costForm.elements.length value in another jsp page. Coz the html page has dynamic rows by the users. and i need the values in the jsp page to know how many rows the user created.
using normal request.getParameter("costForm.elements.length") doesn't workrequest.getParameter() will only get data that's been submitted thru a form or the query string of a URL. You'd have to record the length in a hidden field to read it on the back end, and then you can't just loop thru the fields like that in JSP on the server anyway, unless you have all fields named with a prefix and number, like: field1, field2, field3, etc.
-
SQL Developer 1.5 where are connections stored?
SQL Developer 1.5 where are connections stored?
The connections are in
C:\Documents and Settings\Application Data\SQL Developer/system1.5.0.53.38/o.jdeveloper.db.connection.11.1.1.0.22.49.35/connections.xml
If you want to back them up, you can just right-click export from the tree.
-kris -
Passing values to the JSP page - Urgent
Hi all,
I have to pass the user id value to the JSP page. I have written the following code in the doInitialization() method
IPortalComponentRequest request = (IPortalComponentRequest) this.getRequest();
IPortalComponentContext myContext = request.getComponentContext();
IPortalComponentProfile myProfile = myContext.getProfile();
IAuthentication ia = UMFactory.getAuthenticator();
IUser portalUser = ia.getLoggedInUser(request.getServletRequest(), request.getServletResponse(false) );
s = portalUser.getUniqueName();
IPortalComponentSession componentSession = ((IPortalComponentRequest)getRequest()).getComponentSession();
Object o = componentSession.getValue("myEvents");
myEvents = (LoadEvents)o;
//myEvents = (LoadEvents) myContext.getValue("myEvents");
myEvents.setUserId(s);
myContext.putValue("myBeanName", myEvents);
I have also defined myEvents as a bean in my JSP page with scope APPLICATION. But I get User Id as "NULL".
Thanks in advance.
Rgds,
Janvi.Hi Prakash,
Please find the jsp code pasted below:
<hbj:content
id="myContext">
<hbj:page
title="Successful processing">
<jsp:useBean id="myMeet" scope="application" class="com.sap.ep.bluestar.LoadEvents" />
<jsp:useBean id="myEvents" class="com.sap.ep.bluestar.MonthView" scope="application" />
<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" %>
<%
int leadSpaces, daysInMonth, leadSpaces_next,daysInMonth_next, col_Counter;
myCal.setMonthView();
java.util.Vector printVal_pre = new java.util.Vector();
myCal.printMonth(myCal.getPre_month(),myCal.getPre_year());
printVal_pre = myCal.getPrintValues();
java.util.Vector printVal_cur = new java.util.Vector();
myCal.printMonth(myCal.getCur_month(),myCal.getCur_year());
printVal_cur = myCal.getPrintValues();
java.util.Vector printVal_next = new java.util.Vector();
myCal.printMonth(myCal.getNext_month(),myCal.getNext_year());
printVal_next = myCal.getPrintValues();
if(request.getMethod().equals("POST")){
try {
String action =(String) request.getParameter("action");
if(action.equals("insert")){
// response.sendRedirect("_insertEvent.jsp");
//response.sendRedirect("test.html");
} catch(Exception e) {
System.out.println(e.getMessage());
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<script language="javascript">
function insertEvent(frm,eventDay){
alert("here finally " + eventDay + " " + frm.eventMonth.value + " " + frm.eventYear.value );
frm.action.value = "insert";
frm.submit();
function openWin(frm,eventDay)
var newWin = window.open("http://localhost:50100/irj/servlet/prt/portal/prtroot/Web_Calendar.eventHandler?variable=" + frm.eventMonth.value + "/" + eventDay + "/" + frm.eventYear.value, 'popup',
'resizable,height=200,width=325');
if(newWin.focus) newWin.focus();
</script>
</head>
<body>
User is : <%= myCal.getUserId() %>
<table width="745" height="583" border="0">
<tr>
<td width="258" height="23" align="center"><B> <% out.println(printVal_pre.elementAt(0).toString() + " " + printVal_pre.elementAt(1).toString());
leadSpaces = ((Integer)printVal_pre.elementAt(2)).intValue();
daysInMonth = ((Integer)printVal_pre.elementAt(3)).intValue();
%> </B> </td>
<td width="215"> </td>
<td width="258" align="center"><B> <% out.println(printVal_next.elementAt(0).toString() + " " + printVal_next.elementAt(1).toString());
leadSpaces_next = ((Integer)printVal_next.elementAt(2)).intValue();
daysInMonth_next = ((Integer)printVal_next.elementAt(3)).intValue();
%> </B></td>
</tr>
<tr>
<td height="151"><table width="245" border="1">
<tr>
<th width="35" scope="col"><div align="center">S</div></th>
<th width="35" scope="col"><div align="center">M</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">W</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">F</div></th>
<th width="35" scope="col"><div align="center">S</div></th>
</tr><tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + i + "</td>");
col_Counter++;
} else {
out.print("<td align='center'>" + i + "</td>");
col_Counter++;
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
int cnt = col_Counter;
if(col_Counter == 28){
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++){
out.print("<td> </td>");
cnt++;
if((cnt%7) ==0)
out.println("</tr><tr>");
out.println("</tr>");
%>
</table></td>
<td> </td>
<td><table width="245" border="1">
<tr>
<th width="35" scope="col"><div align="center">S</div></th>
<th width="35" scope="col"><div align="center">M</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">W</div></th>
<th width="35" scope="col"><div align="center">T</div></th>
<th width="35" scope="col"><div align="center">F</div></th>
<th width="35" scope="col"><div align="center">S</div></th>
</tr>
<tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces_next; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth_next; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + i + "</td>");
col_Counter++;
} else {
out.print("<td align='center'>" + i + "</td>");
col_Counter++;
if ((leadSpaces_next + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
cnt = col_Counter;
if(col_Counter == 28){
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++){
out.print("<td> </td>");
cnt++;
if((cnt % 7 ) ==0)
out.println("</tr><tr>");
out.println("</tr>");
%>
</table></td>
</tr>
<tr>
<td colspan="3"><table width="735" height="383" border="1">
<tr>
<td colspan="7" align="center"><B> <% out.println(printVal_cur.elementAt(0).toString() + " " + printVal_cur.elementAt(1).toString());
leadSpaces = ((Integer)printVal_cur.elementAt(2)).intValue();
daysInMonth = ((Integer)printVal_cur.elementAt(3)).intValue();
%> </B></td>
</tr>
<tr>
<th width="105" scope="col">SUN</th>
<th width="105" scope="col">MON</th>
<th width="105" scope="col">TUE</th>
<th width="105" scope="col">WED</th>
<th width="105" scope="col">THUR</th>
<th width="105" scope="col">FRI</th>
<th width="105" scope="col">SAT</th>
</tr>
<form name="eventCal" method="post" action="Web_Cal.jsp">
<input name="eventMonth" type="hidden" value="<%= myCal.getCur_month() + 1 %>">
<input name="eventYear" type="hidden" value="<%=myCal.getCur_year() %>">
<input name="action" type="hidden" value="">
<tr>
<% col_Counter = 0;
for (int i = 0; i < leadSpaces; i++) {
out.print("<td> </td>");
col_Counter++;
for (int i = 1; i <= daysInMonth; i++) {
// This "if" statement is simpler than messing with NumberFormat
if(i < 9) {
out.print("<td align='center'>" + " " + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
col_Counter++;
} else {
out.print("<td align='center'>" + "<a href='javascript:openWin(document.eventCal," + i + ");'>" + i + "</a></td>");
col_Counter++;
if ((leadSpaces + i) % 7 == 0) { // Wrap if EOL
out.println("</tr><tr>");
if(col_Counter == 28){
out.println("</tr>");
}else if(col_Counter < 35){
for(int i = 0; i < (35 - col_Counter);i++)
out.print("<td> </td>");
out.println("</tr>");
}else {
for(int i = 0; i < (42 - col_Counter);i++)
out.print("<td> </td>");
out.println("</tr>");
%> </form>
</table></td>
</tr>
</table>
</body>
</html>
</hbj:textView>
</hbj:page>
</hbj:content>
Regards,
Janvi -
Urgent! pass parameters between jsp pages
Does anyone can give an example about how to pass parameters between jsp pages?
This is what I do:
pageContext.forward("pag_loginc.jsp?p_idusr=" + strUsr + "&c_password=");
But when deployed is not working.
Help is needed.can you put that stuff in the session context in the first page, then pull it out in the second page?
-
HOW to send a value to another jsp page
HOW to send a value to another jsp page, like user name in one jsp page to another jsp page
In the most simplest form...
// pageA.jsp
<html>
<body>
<form action="pageB.jsp" method="post">
<b>First Name:</b> <input type="text" name="FNAME" value="Joe">
<input type="submit" value="Submit">
</form>
</body>
</html>
// pageB.jsp
<html>
<body>
<b>Name:<b> <%=request.getParameter("FNAME")%>
</body>
</html> -
Where are passwords stored on my hard drive, can I access them, alter them
Where are passwords stored on my hard drive/ folder, can I access them and alter them. Can I add passwords to that file/ folder.
Using the Saved Password Editor may be overkill for most users. The quickest way to manipulate saved passwords in Firefox is on the menu bar go to:
Tools -> Options -> Security -> Saved Passwords -> Show Passwords -
I'm watching the tutorial videos. The speaker references downloading the "sample files". Where are these on the video page?
Create complex shapes and refine your illustration | Learn Illustrator CC | Adobe TV
-
Where are Applets stored in WinNT/IE5.5
Hi Folks,
A client is receiving an error saying (not exact)
Java.Lang error cannot find ...class
In Winnt\Downloaded Program Files, Java 1.3.1 is saying it is damaged.
I have reinstalled IE 5.5 but the error remains.
How can I reinstall Java, and/or the Applet.
Where are Applets stored in WinNT/IE5.5?
Thanks in Advance.
SteveBefore you reinstall your JRE/JVM have you tried it in other browsers such as Mozilla, Netscape Navigator, Opera, or others? IExp has taken a giant leap BACKWARDS (IMO) in that it doesn't ship the latest JVM, so it's probably just a browser issue. If its your own applet that you are trying to load, if it works in the appletviewer then there's nothing wrong with your JVM.
-
Values from a jsp page are null in Action Class
hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values received are null.
Here is a part of code:
the jsp file: letter.jsp
<form target="_self" action="/Test/editLetter.do" name="letterTF">
<table>
<tbody>
<tr>
<th>
No of objects
</th>
<th>
Weight
</th>
<th>
Description
</th>
</tr>
<tr>
<td>
Package
<input name="package" id="package" type="checkbox">
</td>
<td>
<input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
</td>
<td>
<input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
</td>
<td>
<input name="description" type="text" value="<%=currentBean.Description()%>"
</td>
</tr>
<tr>
..................................................... <%-- It's a big form --%>
</tr>
<tr>
<input type="submit" name="send" value="Send">
</tr>
</tbody>
</table>
</form>
struts-config.xml:
<form-bean
name="letterTF"
type="Test.LetterForm">
</form-bean>
<action path="/editLetter"
type="Test.LetterAction"
name="scrisoareTF"
input="/letter.jsp"
scope="request"
validate="false">
<forward name="success" path="/index_orders.jsp"/>
</action>
The ActionForm class:
public class LetterForm extends ActionForm{
private String package;
private String package_No;
private String package_weight;
public void setPackage(String package){
this.package = package
public String getPackage(){
return package;
The action class:
public class LetterAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception{
String package;
String package_No;
String package_weight;
LetterForm letterTF = (LetterForm) form;
package = letterTF.getPackage();
package_No = letterTF.getPackageNo()
package_weight = letterTF.getPackageWeight();
System.out.println("Package: "+package);//it will print Package: null
System.out.println("Weight: "+weight);//it will print Weight: null
System.out.println("Description "+description) //it will print Description: null
As I observed its not making the set methods from LetterForm.java
I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea would he be so kind to share it with me.
Thanks in advanced,
DavidBasically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
For Eg:
JSP
<html:form action="accountSearchResults.do">
<html:text property="myName" size="15"/>
//USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
//http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
//THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
//YOUR FORMBEAN WITH getMyName AND setMyName
//METHODS DEFINED
</html:form>
struts-config.xml
<form-beans>
<form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
<form-property name="myName" type="java.lang.String">
</form-property>
</form-bean>
</form-beans>
<action-mappings>
<action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
<forward name="success" path="NextPage.jsp">
</forward>
</action>
</action-mappings>
Action Class
Since we have defined the form bean as a lazyvalidator instance you can use:
PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
SirG -
Values from a jsp page are null in an Action class
hi, i am working on an application...i have a jsp page with several inputs (type=text) and when a submit the form to to my action class all values received are null.
Here is a part of code:
the jsp file: letter.jsp
<form target="_self" action="/Test/editLetter.do" name="letterTF">
<table>
<tbody>
<tr>
<th>
No of objects
</th>
<th>
Weight
</th>
<th>
Description
</th>
</tr>
<tr>
<td>
Package
<input name="package" id="package" type="checkbox">
</td>
<td>
<input name="package_No" type="text" value="<%=currentBean.getPackageNo() %>"> <%-- from session...have to edit some date from a data base--%>
</td>
<td>
<input name="package_weight" type="text" value="<%=currentBean.geWeight()%>">
</td>
<td>
<input name="description" type="text" value="<%=currentBean.Description()%>"
</td></tr>
<tr>
..................................................... <%-- It's a big form --%>
</tr>
<tr>
<input type="submit" name="send" value="Send">
</tr>
</tbody>
</table>
</form>
struts-config.xml:
<form-bean
name="letterTF"
type="Test.LetterForm">
</form-bean>
<action path="/editLetter"
type="Test.LetterAction"
name="scrisoareTF"
input="/letter.jsp"
scope="request"
validate="false">
<forward name="success" path="/index_orders.jsp"/>
</action>
The ActionForm class:
public class LetterForm extends ActionForm{
private String package;
private String package_No;
private String package_weight;
public void setPackage(String package){
this.package = package
public String getPackage(){
return package;
The action class:
public class LetterAction extends Action{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception{
String package;
String package_No;
String package_weight;
LetterForm letterTF = (LetterForm) form;
package = letterTF.getPackage();
package_No = letterTF.getPackageNo()
package_weight = letterTF.getPackageWeight();
System.out.println("Package: "+package);//it will print Package: null
System.out.println("Weight: "+weight);//it will print Weight: null
System.out.println("Description "+description) //it will print Description: null
As I observed its not making the set methods from LetterForm.java
I am dealing with this bug for a couple of days an i didn't managed to break it. If anyone has an idea or a solution would he be so kind to share it with me
Thanks in advance,
DavidBasically your form beans are the place holders or containers for your jsp attributes. It has to be mapped in such a way that when the form is submitted the user entered values get populated on to your form bean.
For Eg:
JSP
<html:form action="accountSearchResults.do">
<html:text property="myName" size="15"/>
//USE ONLY STRUTS TAGS IN JSP's. U CAN REFER TO
//http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
//THE PROPERTY NAME "myName" SHOULD BE DEFINED IN
//YOUR FORMBEAN WITH getMyName AND setMyName
//METHODS DEFINED
</html:form>
struts-config.xml
<form-beans>
<form-bean name="addEditAccount" type="org.apache.struts.validator.LazyValidatorForm">
<form-property name="myName" type="java.lang.String">
</form-property>
</form-bean>
</form-beans>
<action-mappings>
<action path="/accountSearchResults" type="com.zzz.AccountSearchResultAction" name="addEditAccount" scope="request">
<forward name="success" path="NextPage.jsp">
</forward>
</action>
</action-mappings>
Action Class
Since we have defined the form bean as a lazyvalidator instance you can use:
PropertyUtils.copyProperties(targetBean, form);to fetch the values entered by the user. Try to use struts tags in your jsp's and map the properties to your form bean variables. Hope that helps.
SirG
Maybe you are looking for
-
Photos syncing from folder to iPhone all out of order?
I have 2 folders synced to my iPhone 4 photo app. They were previous camera rolls before I set up my phone as a new device. They are all named in order and taken in order, for example IMG_001.jpg was my first picture in my old camera roll. IMG_822.jp
-
Java is not now working with firefox. says its not installed and i have done it 3 times
i can not play online euchre ,any more since i updated my java.no matter how many times i reinstall it , it says i need it. please help
-
1) Can the following be executed at a folder level? a) doc.AddAnnotation b) doc.AddField c) field.AddEvent
-
Can macbook pro retina display updated intel driver,using safari?How?
Hi!how are you ?my name is Chong Hooi Chang,i live in malaysia.i have buy macbook pro retina display,the macbookpro retina display inside have intel HD Graphics 4000,it this need go to intel web site (The Intel Driver Update Utility Installation)upda
-
Hi all, I've run into a problem... Is there anyway where we can do looping in a table in a single SQL query. Basically the scenario is like this : *Consider a table with sample data as follows: SQL> select * from TEST2; EMPNO JOB REL_DT 1 SALESMAN 01