File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Struts question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts question" Watch "Struts question" New topic

Struts question

Prannav Santhosh

Joined: May 09, 2009
Posts: 29
on accessing the url ...http://localhost:9080/LearnStrutsWeb/ , I am calling an Action class , which will in turn gets the info from a DB and populates it to a Value object (ProductTO) and in the ation iam redirecting the request to a JSP (displayAddProductForm.jsp).

The below is the code for the jsp.
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
<%@taglib uri="" prefix="html"%>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
<h3>Add a product</h3>
<html:form action="/saveProduct">
<td>Product Name:</td>
<td><html:text property="productName"/></td>
<td><html:text property="description"/></td>
<td><html:text property="price"/></td>


The action class code.
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
// Get the info from DB.
ProductTO prodto= new ProductTO();

Form productForm11 = (Form)form;

// Finish with
return mapping.findForward("success");

Struts file entry
<action path="/getProduct" type="app02a.action.GetProductAction" name="productForm" validate="false">
<forward name="success" path="/displayAddProductForm.jsp"></forward>

<form-bean name="productForm" type="app02a.form.Form"/>

question here is , when the action class executes the last line of code (mapping.findforward() ) , it redirect to teh JSP and the html fields , with in the JSP's are populated with the value , which i got from the DB. Can some one explain me , how are these fields getting populated.?

Thanks for your help.
I agree. Here's the link:
subject: Struts question
jQuery in Action, 3rd edition