This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Struts and the fly likes struts example -output not display Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts example -output not display" Watch "struts example -output not display" New topic

struts example -output not display

maha lakshmi

Joined: Feb 22, 2008
Posts: 7
i am working on struts example tutorial. its halfly working. ie i got booklist view but i can't view update booklit & delete.its not given any error.......
May be Action forwarding or linking error pls help me thanks in advance.

code is

package com.yourcompany.struts.form;

import java.util.ArrayList;
import java.util.Collection;

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 BooklistForm extends ActionForm {

private static final long serialVersionUID = 1L;

private Collection books;
public Collection getBooks()
return books;

public void setBooks(Collection books)

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
// TODO Auto-generated method stub
return null;

public void reset(ActionMapping mapping, HttpServletRequest request) {
// TODO Auto-generated method stub
books = new ArrayList();
/**********end of**************************/


package com.yourcompany.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.rits.library.SimulateDB;
import com.yourcompany.struts.form.BooklistForm;

public class BookListAction extends Action {

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
BooklistForm booklistForm = (BooklistForm) form;
// TODO Auto-generated method stub
SimulateDB simulateDB = new SimulateDB();

return mapping.findForward("showlist");



<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@ taglib uri="" prefix="bean"%>
<%@ taglib uri="" prefix="html"%>
<%@ taglib uri="" prefix="logic"%>

<title>Show book list</title>
<table border="1">
<%-- set the header --%>
<td>Book name</td>
<td> </td>
<td> </td>
<%-- check if book exists and display message or iterate over books --%>

<logic:notEmpty name="booklistForm" property="books">
<logic:iterate name="booklistForm" property="books" id="book">
<%-- print out the book informations --%>
<td><bean:write name="book" property="author" /></td>
<td><bean:write name="book" property="title" /></td>
<td><html:checkbox disabled="true" name="book" property="available" /></td>
<%-- print out the edit and delete link for each book --%>

<td><html:link action="" paramName="book"
paramProperty="id" paramId="id">Edit</html:link></td>
<td><html:link action="" paramName="book"
paramProperty="id" paramId="id">Delete</html:link></td>
<%-- print out the add link --%>
<td colspan="5"> <html:link action="/jsp/bookAdd.jsp">Add a new book</html:link> </td>
<%-- end interate --%>


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "">

<data-sources />
<form-bean name="booklistForm" type="com.yourcompany.struts.form.BooklistForm" />
<form-bean name="bookEditForm" type="com.yourcompany.struts.form.BookEditForm" />

<global-exceptions />
<global-forwards >
<forward name="welcome" path="/" redirect="true" />


<action-mappings >
<action forward="/jsp/index.jsp" path="/default" unknown="true" />

scope= "request"
type = "com.yourcompany.struts.action.BookListAction"
validate="false" >
<forward name="showlist" path="/jsp/booklist.jsp" />
<forward name="showlist" path="/" redirect="true" />
<forward name="showAdd" path="/jsp/bookAdd.jsp" />
<forward name="showEdit" path="/jsp/bookEdit.jsp" />


<message-resources parameter="com.yourcompany.struts.ApplicationResources" />

I agree. Here's the link:
subject: struts example -output not display
It's not a secret anymore!