Click to See Complete Forum and Search --> : Package javax.servlet.jsp Error Message!!!
mistreated
11-15-2005, 12:50 AM
Hi All,
I really need some help with my application. I'm a total newbie to Java and my other programming languages aren't that spectacular either.
After compiling my java file, I've received the following errors:
(i) package javax.servlet.jsp does not exist
(ii) package javax.servlet.jsp.tagext does not exist.
I read through some websites to get more info but still can't get a grip on it.
For the record, I'm using Tomcat 4.1 and it's located at the following directory:
C:\Program Files\Apache Group\Tomcat 4.1
My files are then been saved at:
C:\Program Files\Apache Group\Tomcat 4.1\webapps\MyFiles.
I'm really am very confused and would truly appreciate some help. I believe that the problem lies in the servlet.jar files or classpath is wandering around somewhere.
Btw where should i appropriately save my .java files? Can I saved it in the same folder as my jsp files or seperately.
I hope I make it out clear here, coz sometimes I'm not even sure what I am doing. Somebody help me please?!!
Thank You..
Both of those packages are in the jsp-api.jar, not the servlet one.
You should have your .java files in: /yourapp/WEB-INF/src/java/
Classes and packages in: /yourapp/WEB-INF/classes/
These are not inforced by have been adopted as a common convention. I dont like abbreviations so I use "source" instead of "src" for example.
If you have classpath problems, read Khalid Ali's sticky post at the top of this forum. Im pretty sure he covers these issues there.
All the best.
mistreated
11-16-2005, 04:51 AM
Hey there, thankz for the tips! but still need a little bit more advise.
I did what you asked about placing my .java file. But when I compiled it, I've realised that my CreateApp.class files was placed automatically in the following directory:
:\WEB-INF\src\java\com\myapp\CreateApp.
So what I did was I cut this whole the \com\myapp\CreateApp directory and paste it to WEB-INF\classes. Err...is it right to do so? Hence when I try to compile and run in dos-prompt, i 've successfully compiled it but weren't able to execute it. I received the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: CreateApp
When I put it back at it's original location, i've received the same error while trying to execute it.
When I try run the browser to my JSP page that uses bits and piece of the java file, it gives the following exception:
org.apache.jasper.JasperException: Unable to compile class for JSP.
What's actually wrong here?? The location of my class files again? Hope you can help me out.. THankz
You shouldnt manually cut and paste the compiled classes, they should go to the right place to start with.
It sounds like a classpath issue to me so I would once again recommend reading the post that I suggested before... if you havent already that is.
It seems that the location to your class files is not in the classpath.
mistreated
11-16-2005, 08:23 PM
Ook..thankz a lot mate! I read through the post, follow the instructions and all. Nvm i check my classpath again.. It's really killing me man!
Khalid Ali
11-17-2005, 12:57 AM
hunm...frustrated eh?...
well do the following.
show us your complete directory structure, where you compile the files from , how do u compile them, how do the end up in the web-inf folder, where are the jsp pages. etc..give us everything...
mistreated
11-17-2005, 01:52 AM
Hey, thankz a lot to the both of you man! I've finally able to compile and execute my files and it's working fine. Khalid Ali's sticky post have really been a lot of help. What I did was I created a new project workspace (I'm using Xinox JCreator LE) and then check through the class path and source and just run through the sticky post many times (though I dun think it's necessary, just being paranoid. ahakz)!!
Guess now I got to move on to my JSP files and Oracle Database stuff! Might need some help in the future again! :) Thankz again guys!
CheerS!
Khalid Ali
11-17-2005, 02:42 PM
Hey its always pleasure to help and see people solve problems..:-)
sweet deal..
Have fun and don't hesitate to ask any questions if you get any sql(roacle related) issues...
mistreated
11-17-2005, 09:15 PM
Hey guys! It's me again. Currently i'm doing my JSP page and I'm trying to connect it to the Oracle database. But i've always received the exception report while trying to run the page. It's a HTTP status 500 error with the following exception: java.lang.IllegalStateException. What does this mean? I just give you my codes for reference:
<%@ page language="java" contentType="text/html"%>
<%@ page session="false" %>
<%@ page import="java.sql.*" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
<%
Connection conn;
ResultSet resultSet;
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
}
catch(ClassNotFoundException e)
{
System.out.println("Driver not found.");
System.out.println(e.toString());
throw new UnavailableException(this, "Class Not Found.");
}
try
{
conn = DriverManager.getConnection("jdbc:oracle:thin:@xx.x.xx.xxx:xxxx", "abc", "def");
Statement statement = conn.createStatement();
resultSet = statement.executeQuery("SELECT EMPLOYEE_ID,EMPLOYEE_NAME,DEPARTMENT,"
+ "FROM user_accounts_dm");
}
catch(SQLException e)
{
System.out.println("An error occurs.");
System.out.println(e.toString());
throw new UnavailableException(this, "Cannot connect with the specified database.");
}
%>
At this point of time, the JSP page could not even connect to the database. What is it that I'm missing? Or is just got to do with the file placement? Not again!!
Also when i tried to compile my .java file with the following imports:
import javax.servlet.jsp.*;
import javax.servlet.http.*;
import org.apache.jasper.runtime.*;
it gives me compilation error: package does not exist.
To be honest, I have a little bit difficulty understanding the thing about packages. I've never learnt java before and i'm given a java task! and i'm running out of time to complete. Would really appreciate some help..
Khalid Ali
11-17-2005, 10:31 PM
you need to post the full stack trace for illegal state...so that one can take a look and determine where it could have been cuased from...
An advice for you will be that "DO NOT" put your business logic in your jsp pages(no db code in jsp nor any other processing in jsp
Use servlets or simple POJO's (Plain old java objects) for such purposes.
mistreated
11-22-2005, 02:57 AM
Hi! I need some help again. I'm still trying to connect my jsp pages to the Oracle Database. Well the classes and jsp pages seems to be ok. Hope so. :) Ayw I read a few forums and came to note that I need a Oracle driver (i.e ojdbc14.jar). Hence i downloaded it and the problem is, where should I actually place the driver? And do I need to set the classpath for it as well? I will get
Errorjava.sql.SQLException: Io exception: The Network Adapter could not establish the connection error message on the browser. What should i do here?? Sorry, I'm really a newbie in this man! Thankz and wld appreciate any help.