Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Struts question  RSS feed

Prannav Santhosh
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!