i applied the code that you had posted ... but if the Document is not prefixed with the word public then i cannot access the method in the JSP .. so i have added the word public to the method ... now i can acceess the method in JSP .... but when i try to execute the program .. .i get this error ...
java.lang.IllegalAccessError: try to access method atmmachine.pp.createDocument(Ljava/lang/String;Ljava/lang/String Lcom/lowagie/text/Document; from class org.apache.jsp.Detail_0005fInterface$jsp
at org.apache.jsp.Detail_0005fInterface$jsp._jspService(Detail_0005fInterface$jsp.java:113)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:484)
my class file code is as follows
package atmmachine;
import java.io.FileOutputStream;
import java.io.IOException;
import com.lowagie.text.*;
import com.lowagie.text.pdf.PdfWriter;
public class pp {
public Document createDocument(String filename, String helloString)
{
Document document = new Document();
try
{
PdfWriter.getInstance(document, new FileOutputStream(filename));
document.open();
document.add(new Paragraph(helloString));
}
catch(DocumentException de)
{
System.err.println(de.getMessage());
}
catch(IOException ioe)
{
System.err.println(ioe.getMessage());
}
document.close();
return document;
}
}
and my JSP code is
<%@ page contentType="text/html; charset=windows-1252" language="java" import="java.sql.*,java.io.*,java.util.*,java.sql.*,java.text.*,java.util.Date,java.*,com.lowagie.text.*,com.lowagie.text.pdf.PdfWriter" %>
<%@ page session = "true"%>
<jsp:useBean id="text123" scope="session" class="atmmachine.pp" />
<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns
="urn:schemas-microsoft-com
ffice
ffice" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Language" content="en-us">
<meta name="GENERATOR" content="Microsoft FrontPage 5.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>ADD DETAILS - INTERFACE</title>
</head>
<body>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://128.1.2.3:3306/itsupport","cbqnet","cbqnet");
atmmachine.pp create = new atmmachine.pp();
String filename = "test123.pdf";
String helloString = "created the acrobat document";
create.createDocument(filename, helloString);
%>
</body>
</html>