Vijay Arora

Greenhorn
+ Follow
since Jun 25, 2007
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Vijay Arora

I m facing problem while generating PDF using Japer report. below is the servlet code that is handlig client request.

response.setContentType("application/pdf");
response.setHeader("Content-disposition","attachment; filename=\""+ReportName+""+currDate+".pdf \"");
response.getOutputStream().write(optionHoldingsReport.generateOptionHoldingsReport(jrxmlPath));
response.flushBuffer();

And generateOptionHoldingsReport method returns byte array and i am writiing this byte array to the outputstream..below is code of this method.

public byte[] generateOptionHoldingsReport(String jrxmlPath) throws Exception
{
logger.debug("[OptioHoldingsReport - Inside generateOptioHoldingsReport() :] ");
logger.info("jrxmlPath:"+jrxmlPath);
List dataList=new ArrayList();
byte[] reportData=null;
HashMap parameters = new HashMap();
JasperPrint jasperPrint;
try
{
logger.info("ReportConstants.HEADER_IMAGE_PATH:"+ReportConstants.HEADER_IMAGE_PATH);
parameters.put("imagePath", ReportConstants.HEADER_IMAGE_PATH);
dataList= populateData();

JasperReport jasperReport = JasperManager.loadReport(jrxmlPath);
logger.info("jasperReport: "+jasperReport);
JRBeanCollectionDataSource ds = new JRBeanCollectionDataSource(dataList);
logger.info("ds: "+ds);
reportData = JasperRunManager.runReportToPdf(jasperReport,parameters, ds);
logger.info("reportData: "+reportData);
//jasperPrint = JasperFillManager.fillReport(jasperReport,parameters, ds);
//JasperExportManager.exportReportToPdfStream(jasperPrint,servletOutputStream);
logger.info("Exit");
}
catch(Exception e)
{
logger.error("[ OptioHoldingsReport - generateOptioHoldingsReport ():] Exception is "+e.getMessage());
}
return reportData;
}

this api is not throwing any exeption but its not printing below line in logger. and adobe reader is showing error that it can not open pdf file due to unsupported type format.
logger.info("reportData: "+reportData);



What change i should make to generate proper PDF file.
Please suggest.



12 years ago
Hi,
I m using struts 1.1 and while using validation framework i m getting following error.
Error:
[8/26/09 17:09:47:391 IST] 00000041 ComposableReq I org.apache.struts.chain.ComposableRequestProcessor init Initializing composable request processor for module prefix ''
[8/26/09 17:09:47:469 IST] 00000041 ValidatorForm E org.apache.struts.validator.ValidatorForm validate No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)
org.apache.commons.validator.ValidatorException: No such validation method: org.apache.struts.validator.FieldChecks.validateRequired(java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest)



Validaion.xml:


<form-validation>
<formset>
<form name="registerForm">
<field property="uname" depends="required">
</field>
<field property="lname" depends="required">
</field>
<field property="age" depends="intRange">
<arg0 key="registration.lookup.field3"/>
<arg1 key="${var:min}" name="min" resource="false" />
<arg2 key="${var:max}" name="max" resource="false"/>
<var>
<var-name>min</var-name>
<var-value>10</var-value>
</var>
<var>
<var-name>max</var-name>
<var-value>20</var-value>
</var>
</field>
</form>
</formset>
</form-validation>

And Validaion-rules.xml:

<form-validation>

<global>
<validator name="required"
classname="org.apache.struts.validator.FieldChecks"
method="validateRequired"
methodParams="java.lang.Object,
org.apache.commons.validator.ValidatorAction,
org.apache.commons.validator.Field,
org.apache.struts.action.ActionErrors,
javax.servlet.http.HttpServletRequest"
msg="errors.required">
</global>

</form-validation>
12 years ago
Hi....I want to learn spring.
Please suggest any good book for this.
Beginning Spring Framework 2 (Wrox) ...Is it a good book for learners.

13 years ago
I have 4 submit buttons in my jsp page and on click of each button i generate different report.on submiting i want to pass a value for each report to a single servlet.and there i will check that if value of parameter is this then call that method i this then that.

How can i do this ???

Please help..
Thanks
[ November 16, 2008: Message edited by: Bear Bibeault ]
i have written data to xls using jxl api but how can i give option to user to save this fxls file on his machine.
i have called a jsp file from js function and this jsp is writinig data to xls and saving it to server directory but i want to give user a option to save this file on his machine.i have set contenttype also.
response.setContentType("application/vnd.excel-msdownload");

response.setHeader("Content-Disposition","attachment;filename=\""+"filename" );

Is there any way.....?
13 years ago
JSP
Hi all,
can anyone help me....
var objDataform=document.forms["CRP_FORM"];
var url="..\\..\\..\\..\\webdesktop\\CRP\\InsertData.jsp";
var ReturnVal=Fun_Ajax(url,'');

How can i pass form object (objDataform) to jsp so that in JSP i can retrieve values of fileds on the form and insert their values into a table.
Above code written in a JS file and i m using AJAX.

Thanks..
13 years ago
JSP
Hi all,
can anyone help me....
var objDataform=document.forms["CRP_FORM"];
var url="..\\..\\..\\..\\webdesktop\\CRP\\InsertData.jsp";
var ReturnVal=Fun_Ajax(url,'');

How can i pass form object (objDataform) to jsp so that in JSP i can retrieve values of fileds on the form and insert their values into a table.
Above code written in a JS file and i m using AJAX.

Thanks..
coz i m learning Java.


Thanks & Regards
14 years ago
How can i count number of objects created in my program.
I want to count all String ,Array or any object that is created during my program execution.
14 years ago
I got this compilation error:
can not find symbol:constructor Animal()
There is compilation error in the Code.Why???
class Animal
{
Animal(String name)
{
System.out.println("ANIMAL NAME="+name);
}
}
class Dog extends Animal
{
Dog(String h)
{
}

}
public class Three{
public static void main (String [] args)
{
new Animal("Giraffe");
}
}
In this code compiler will not create default constructor for Dog
Class.But still there is compilation error.Why???
class Animal
{
Animal(String name)
{
System.out.println("ANIMAL NAME="+name);
}
}
class Dog extends Animal
{
Dog(String h)
{
}

}
public class Three{
public static void main (String [] args)
{
new Animal("Giraffe");
}
}
What is difference between type 1,type 2,type 3,type 4 drivers.
Please point out some major difference other than performance.

[edited subject to UseRealWords - b/w is not a real word]
[ May 12, 2008: Message edited by: Jeanne Boyarsky ]
Ya sure..following is the url where i found the above quote

Compiling a blank file??
14 years ago

Imagine that you have two files, A.java and B.java containing classes A and B. Furthermore, imagine that class A mentions class B. Now, you type "javac A.java". At some point, the compiler is going to look for B.class, and since it doesn't exist yet, what should the compiler do? Of course, what it does is look for "B.java" and expect class B to be defined in it. If B.java instead contained class C, and C.java contained class B, then the compiler would fail to compile anything.

So even without the rule about one public class per file, you can see another common sense rule: if a class is referenced outside of the source file in which it is defined, the source file should be named after the class. Many Java compilers will warn about violations of this even for non-public classes.

Now, the only reason for a class to be public is for it to be used outside of its own source file, right? So it makes sense to make the rule stronger in this case. The common-sense rule, the one that people follow consciously or not, is that a source file should contain at most one class that is ever mentioned by name outside of the file, and the file should be named after that one class.



Thanks Campbell for the hint..searched through the forum and found the above information.
[ April 14, 2008: Message edited by: Vijay Arora ]
14 years ago