i want to use a connection class from my jsp page to avoid call connection from every jsp page.
I am using apache/tomcat. can i keep the class file in the same folder where my jsp resides.
please help me
Herman Schelti
Ranch Hand
Joined: Jul 17, 2006
Posts: 387
posted
0
No.
In a webapplication your classes will go into a folder inside WEB-INF/classes. (or in a .jar file inside WEB-INF/lib)
Your .jsp (the sources) will not be there, and the compiled versions certainly will not be there.
Herman
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12271
1
posted
0
I am using apache/tomcat. can i keep the class file in the same folder where my jsp resides.
The usual Tomcat installation includes a class-loader-howto.html file which explains exactly where class files should be placed. Also see the API for details of web application directory structure.
If you are talking about a database connection Tomcat has a facility for maintaining a pool of connections.
My problem is not solved. My package is kept in "WEB-INF/classes/connection" and jsp is kept in same level of folder stucture where WEB-INF is kept. My error message is "Package connection not found in import"
I am using this syntax to import the package. <%@page language="java" import="java.sql.*,connection.*" %>
I am using solaris OS with tomcat version 3.2.4. Can anybody tell me where I am going wrong.
"confused confused", you have previously been warned on one or more occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it prior to your next post.
Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.
Be aware that accounts with invalid display names are disabled.
I am really very sorry. And I have changed my Profile name.
Nishanth Sivaraman
Greenhorn
Joined: Aug 12, 2008
Posts: 7
posted
0
You can place your class file in folder \WEB-INF\classes\connection in your web application. since the package name is connection.
Nishant Kr
Greenhorn
Joined: Aug 07, 2008
Posts: 8
posted
0
Hi Preeti, I think it'll be better if you place all your class files in a package inside the src folder and the jsp files into another in the web folder, and then import all those classes from there into their respective jsp files. Now, you can create a db connection class file and place it in the same package to that of other class files.
CONPool is the pool name that is coming from your ds.xml file.
Import DbConnection in each of the class files for the JSP pages. Create the connection globally inside the class by calling the method getConn() in a costructor, and use it to call your db procedures. Remember to create a method closing the connection at the end of the class file. You can close the connection by calling this method at the end of its respective jsp file.
"Nishant Kr", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.
Failure to comply will result in the removal of your account.
bear JavaRanch Sheriff
Preeti Roy
Greenhorn
Joined: Aug 08, 2008
Posts: 8
posted
0
Thank you All for resonding my problem. As per the convention I have kept my package in the WEB-INF/classes folder. But still not able to import the PACKAGE. My jsp is saying package not found ti import. Tell me something my i have complied my class jsdk1.4 and in the server my jsdk version is 1.5 . IS there any versiing problem.
I don't want to follow other way apart from package import to access connection class. Can any body post the code where I can include jsp connection file in other file.
Please help me as soon as possible. I am really in trouble. For Information: OS- solaris 5.10, tomcat -3.2.4, jDk 1.5