nemanzini Posted August 14, 2007 Share Posted August 14, 2007 Hi guys, I'm new at java and jasper. I have created reports using JasperReports and iReport but have to make my reports more dynamic. Users should be able to select columns that should appear on report.I have tried going thru the article- http://www.ibm.com/developerworks/websphere/library/techarticles/0505_olivieri/0505_olivieri.htmlbut have an error that reads - identify expected at this line :- BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream));here is the complete code:import org.apache.velocity.Template;import org.apache.velocity.app.Velocity;import org.apache.velocity.context.Context;import org.apache.velocity.exception.ParseErrorException;import org.apache.velocity.exception.ResourceNotFoundException;import org.apache.velocity.servlet.VelocityServlet; import java.io.BufferedWriter;import java.io.PipedInputStream;import java.io.PipedOutputStream; import javax.servlet.ServletConfig;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.util.Properties; public class VelocityTest extends VelocityServlet { protected Properties loadConfiguration(ServletConfig config) {Properties properties = new Properties();properties.setProperty(Velocity.FILE_RESOURCE_LOADER_PATH, config.getServletContext().getRealPath("/")); return properties;} public Template handleRequest(HttpServletRequest request, HttpServletResponse response, Context context) { context.put("sql","SELECT * from wcs.tblpayments");String fieldList[] = {"PAYMENT_NO","WCS_NUMBER","CONTRACT_NO","PAYMENT_INDICATOR","DIVISION_CODE","BENEFICIARY_CODE"," ADVICE_NUMBER"};context.put("title","testing Velocity");context.put("$headerString","HEADER");context.put("fieldList",fieldList);Template template = null;PipedInputStream inStream;BufferedWriter writer ;Thread thread;PipedOutputStream outStream;TemplateCompiler compiler;try { PipedOutputStream outStream = new PipedOutputStream(); BufferedWriter writer = new BufferedWriter(new, OutputStreamWriter(outStream)); // Connect input stream to output streaminStream = new PipedInputStream(outStream);compiler = new TemplateCompiler(inStream);thread = new Thread(compiler);thread.start();template.merge(context, writer);template = getTemplate("BasicReport.vm"); // tpl = getTemplate("hello.vm");} catch (ResourceNotFoundException e) {e.printStackTrace();} catch (ParseErrorException e) {e.printStackTrace();} catch (Exception e) {e.printStackTrace(); } finally {if (writer != null) {writer.flush();writer.close();}}thread.join();// Get compiled reportreturn (compiler.getJasperReport());} } any assistance will be greatly appreciated Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now