Using a Java Object in a JSP

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Aug 2005
Posts: 2
Reputation: Max_05 is an unknown quantity at this point 
Solved Threads: 0
Max_05 Max_05 is offline Offline
Newbie Poster

Using a Java Object in a JSP

 
0
  #1
Aug 5th, 2005
Hi,
Can any one tell me how to use a Java Object in a JSP file i.e I have written a connection class and want to instantiate an object of this class so that the JSP can connect to the database. Do I have to import it or include it ?? :-|
Reply With Quote Quick reply to this message  
Join Date: Nov 2004
Posts: 6,143
Reputation: jwenting is just really nice jwenting is just really nice jwenting is just really nice jwenting is just really nice 
Solved Threads: 212
Team Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Using a Java Object in a JSP

 
0
  #2
Aug 5th, 2005
The JSP will need to have access to the class of course. That means importing the package the class is in.
After that you can instantiate it like everything else.

BUT (and that's a very big BUT) you should really not do that. You should use a servlet for stuff like that and use the JSP (which you should build using JSTL) only for displaying results.

You should at all times strive to write JSPs without any Java code at all.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 2,108
Reputation: server_crash is on a distinguished road 
Solved Threads: 18
server_crash server_crash is offline Offline
Postaholic

Re: Using a Java Object in a JSP

 
0
  #3
Aug 5th, 2005
You should like he said split things up. If I remember right it's called MVC architecture, and is worth looking into.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC