Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

where to place Bean file(*.class)in Tomcat server

 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I created a simple application for getting name,age and so on.Then By hitting submit will show the values entered in a session.So i created a Java file with getters and setters for Name, age and so on.
<jsp:useBean id="user" class="UserData" scope="session"/>
where i have to store this UserData.class file.
scrathing my head for long time
Thanks in Advance
Srinivas
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Place the Class file for the bean in a folder under WEB-INF/classes.
 
Srinivas Genji
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks for Reply,i placed class file in web-inf/classes
but still i`m getting these errors,org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.


An error occurred at line: 6 in the jsp file: /JSP/Test.jsp

Generated servlet error:
C:\Program Files\ApacheTomcat 4.0\work\localhost\_\JSP\Test$jsp.java:86: Class org.apache.jsp.UserData not found.
UserData user = null;
^


An error occurred at line: 6 in the jsp file: /JSP/Test.jsp

Generated servlet error:
C:\Program Files\ApacheTomcat 4.0\work\localhost\_\JSP\Test$jsp.java:89: Class org.apache.jsp.UserData not found.
user= (UserData)
^


An error occurred at line: 6 in the jsp file: /JSP/Test.jsp

Generated servlet error:
C:\Program Files\ApacheTomcat 4.0\work\localhost\_\JSP\Test$jsp.java:94: Class org.apache.jsp.UserData not found.
user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
^
3 errors, 1 warning


Any reply appreciated
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
This is a recording

Do not use the default package. Create a package directory structure under WEB-INF/classes, and put the package specification at the beginning of all your JavaBean classes.
 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Ya Nathan is rite .


U can follow this code :






Beans should always be associated with some package other than DEFAULT.
 
Srinivas Genji
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Thanks Nathan and Rishi for helping me,
Now its working fine.
cheers mate
Srinivas
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Still i m getting the same error as the above my class file is
placed my class file in (C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\classes)
package user;
public class UserData {
String username;
String email;
int age;
public UserData(){
}
/*public void setUsername( String value )
{
username = value;
}

public void setEmail( String value )
{
email = value;
}

public void setAge( int value )
{
age = value;
}*/

public String getUsername() { return "jothi"; }

public String getEmail() { return "yahoo"; }

public int getAge() { return 10; }
}

MY jsp page is
<jsp:useBean id="user" class="user.UserData" scope="session"/>
<jsp:getProperty name="user" property="*" />
<HTML>
<BODY>
You entered<BR>
Name: <%= user.getUsername() %><BR>
Email: <%= user.getEmail() %><BR>
Age: <%= user.getAge() %><BR>
</BODY>
</HTML>
error i got is that
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: -1 in the jsp file: null

Generated servlet error:
[javac] Since fork is true, ignoring compiler setting.
[javac] Compiling 1 source file
[javac] Since fork is true, ignoring compiler setting.
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SaveName_jsp.java:41: cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] UserData user = null;
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SaveName_jsp.java:43: cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] user = (UserData) pageContext.getAttribute("user", PageContext.SESSION_SCOPE);
[javac] ^
[javac] C:\Program Files\Apache Group\Tomcat 4.1\work\Standalone\localhost\_\SaveName_jsp.java:46: cannot resolve symbol
[javac] symbol : class UserData
[javac] location: class org.apache.jsp.SaveName_jsp
[javac] user = (UserData) java.beans.Beans.instantiate(this.getClass().getClassLoader(), "UserData");
[javac] ^
[javac] 3 errors

Help is urgently needed
thanks in advance
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
i have placed the class file in the path C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

Originally posted by jothi chokalingam:
i have placed the class file in the path C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes



Should be:
C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes\YOUR PACKAGE\yourFile.class

The directory structure has to match the package structure.
[ January 02, 2006: Message edited by: Ben Souther ]
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hi Ben Souther ,
You mean to say it to be like this path...
C:\Program Files\Apache Group\Tomcat 4.1\webapps\ROOT\WEB-INF\classes\user\UserData.class
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I m using jasper reports to my project...
here is my servlet class i m using ..
i want to get the output from of the pdf file in client side...
but i m not getting the stream of pdf in client side...
even there is no errror showing in the tomcat server when i load nthis servlet using an html file ......
help is needed urgently

/* Program or JASPER Engine to convert the .JRXML file to a report and the exporting it to .PDF file */
import net.sf.jasperreports.engine.JasperCompileManager;
import net.sf.jasperreports.engine.JasperFillManager;
import net.sf.jasperreports.engine.JasperPrintManager;
import net.sf.jasperreports.engine.JasperExportManager;
import net.sf.jasperreports.engine.xml.JRXmlLoader;
import net.sf.jasperreports.engine.JRException;
import java.io.*;
import java.net.*;
import java.sql.*;
import java.util.*;
import java.sql.*;
import java.io.File;
import java.util.Date;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.view.JasperViewer;
import net.sf.jasperreports.engine.JasperPrintManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletOutputStream;
import java.io.PrintWriter;
import java.io.IOException;
public class SimpleServlet extends HttpServlet{

public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException{


try{
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Class.forName ("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection("jdbc racle:thin:@10.236.8.49:1521:heb","hebuser","hebpass");
// @machineName ort:SID, userid, password
//int i=0,j=0;
String query = "select * from storeevent1";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(query);


System.out.println("The context path is >>>>>>>>>> " + request.getContextPath());
/
String src= "/heb.jrxml";
net.sf.jasperreports.engine.design.JasperDesign jDesign = net.sf.jasperreports.engine.xml.JRXmlLoader.load(src);
JasperReport jReport = net.sf.jasperreports.engine.JasperCompileManager.compileReport(jDesign);

Map p1 = new HashMap();

JasperPrint jPrint= JasperFillManager.fillReport( jReport,null,conn );

OutputStream out = response.getOutputStream();
net.sf.jasperreports.engine.JasperExportManager.exportReportToPdfStream(jPrint,out);
System.out.println(jPrint);
System.out.println(out);
System.out.println("next");
rs.close();
stmt.close();
conn.close();
}
catch(Exception e)
{
e.printStackTrace();
}

}
}

help me regarding this
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
jothi,

I hadn't noticed earlier that you tacked your question onto someone else's thread. This is called hi-jacking a thread and is considered rude.
Your last post is completely unrelated.
Please start a new thread with this new question.

Thank you
-Ben
[ January 05, 2006: Message edited by: Ben Souther ]
 
jothish chokkalingam
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
yes ben i have posted a new thread
reg opening a pdf file created by jasper in client side
can you please solve position
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic