jQuery in Action, 2nd edition*
The moose likes JSP and the fly likes Instantiating a class from inside a jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Instantiating a class from inside a jsp" Watch "Instantiating a class from inside a jsp" New topic
Author

Instantiating a class from inside a jsp

aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
Hi all,
I have the following file structure:
Project
--> src
--> java
--> a class called "Row.java"
--> Web
--> main.jsp

my question is how can the jsp main know where the class Row is so that it can instantiate objects from the class and do something like:
Row r = (Row) request.getAttribute("row");

thank you..
Regards,
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

See the Servlet Specification. Your web application must follow certain rules so that it can do things such as finding the classes. Your class files must be in a package other than the default, and must either be placed in the folder hierarchy under WEB-INF/classes, or zipped up into a jar file and placed in WEB-INF/lib.

The source (.java) files are not part of the application.
[ April 15, 2006: Message edited by: Bear Bibeault ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
hey,
I am actually using the netBeans IDE for developping this application.
and it's by default set all the file hierarchy.
How can I deal with that ?
aymane chetibi
Ranch Hand

Joined: Apr 12, 2006
Posts: 175
and yes, when the project is built all the compiled java code is placed in build/web/WEB-INF/classes
where the jsps are placed in: build/web
thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Instantiating a class from inside a jsp
 
Similar Threads
change bgcolor of row dynamically ???
Problem in hiding the row of data
How to iterate over one List and get a nested property defined in a different List
JSP Invoking another JSP in Iframe
Weird Question