struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "@rju" <>
Subject Re: result type Jasper [Struts 2]
Date Tue, 16 Nov 2010 04:34:55 GMT

ok boss let me shou you my files
<?xml version="1.0" encoding="UTF-8" ?>


<?xml version="1.0" encoding="UTF-8"?>



<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="/struts-tags" prefix="s" %>
String path = request.getContextPath();
String basePath =

    My JSP 'index.jsp' starting page



package com;

public class Person {

    private Long id;

    private String name;

    private String lastName;

    public Person() {

    public Person(String name, String lastName) { = name;
        this.lastName = lastName;

    public Person(Long id, String name, String lastName) { = id; = name;
        this.lastName = lastName;

    public Long getId() {
        return id;

    public void setId(Long id) { = id;

    public String getLastName() {
        return lastName;

    public void setLastName(String lastName) {
        this.lastName = lastName;

    public String getName() {
        return name;

    public void setName(String name) { = name;
package com.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import com.opensymphony.xwork2.ActionSupport;

import net.sf.jasperreports.engine.JasperCompileManager;
import com.Person;

public class JasperAction extends ActionSupport {

	private static final long serialVersionUID = 1L;
	/** List to use as our JasperReports dataSource. */
    private List myList;

	public String execute() throws Exception {

        // Create some imaginary persons.
        Person p1 = new Person(new Long(1), "Patrick", "Lightbuddie");
        Person p2 = new Person(new Long(2), "Jason", "Carrora");
        Person p3 = new Person(new Long(3), "Alexandru", "Papesco");
        Person p4 = new Person(new Long(4), "Jay", "Boss");

        // Store people in our dataSource list (normally they would come
from a database).
        myList = new ArrayList();

        // Normally we would provide a pre-compiled .jrxml file
        // or check to make sure we don't compile on every request.
        try {
        	ServletContext context = null ; 
        	context = ServletActionContext.getServletContext();
        } catch (Exception e) {
            return ERROR;

        return SUCCESS;

    public List getMyList() {
        return myList;
This is the thing
and i have placed my Report.jrxml and Report.jasper in the directory called
and i am trying to place this directory in every place i.e. once in
"classes" folder, root folder, web-inf folder i am trying all and project is
running Report button is coming but after pressing the Report Button am not
getting out put.. You can see the ouputs in my attachmens. namely
Output1,Output2. In that you can find the directory structure i have
flollowed.... Please Please help me... 
View this message in context:
Sent from the Struts - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message