struts-user mailing list archives

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

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



	
		 
            
    
		
		
			/jasper/Report.jasper
			myList
			PDF
		
		
	

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

 
  struts2
  org.apache.struts2.dispatcher.FilterDispatcher
 
 
  struts2
  /*
 
 
  index.jsp
 




--------------------------------------------------------------
--------index.jsp------------

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



  
    ">
    
    My JSP 'index.jsp' starting page
	
	
	    
	
	
	
  
  
  

	

  

--------------------------------------------------------
-----person.java-----------
package com;

public class Person {

    private Long id;

    private String name;

    private String lastName;

    public Person() {
    }

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

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

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.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) {
        this.name = name;
    }
  
}
------------------------------------
---------JasperAction.java----------
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();
        myList.add(p1);
        myList.add(p2);
        myList.add(p3);
        myList.add(p4);

        // 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();
        	
        	
JasperCompileManager.compileReportToFile(context.getRealPath("/jasper/Report.jrxml"),context.getRealPath("/jasper/Report.jasper"));
        	 
        
        } catch (Exception e) {
            e.printStackTrace();
            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
"jasper".
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...

http://old.nabble.com/file/p30225819/Output1.jpg 
http://old.nabble.com/file/p30225819/Output2.jpg 
-- 
View this message in context: http://old.nabble.com/result-type-Jasper--Struts-2--tp11004749p30225819.html
Sent from the Struts - User mailing list archive at Nabble.com.

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