Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

browser returning error  RSS feed

 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have made the following jsp page
<jsp:directive.page import="java.sql.*" />
<jsp:scriptlet>
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection("jdbcracleci:@xe","hr","hr");
Statement stmnt = con.createStatement();
ResultSet rs=stmnt.executeQuery("select * from countries");
rs.first();
String country = rs.getString("COUNTRY_NAME");
statement.close();
connection.close();
}
catch (Exception E) {out.println(E.getmessage());}
</jsp:scriptlet>
<HTML>
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
</BODY>
BUT THE BROWSER from tomcat RETURNS THE FOLLOWING ERROR

org.apache.jasper.JasperException: Unable to compile class for JSP:

An error occurred at line: 2 in the jsp file: /connection.jsp
statement cannot be resolved
1: <jsp:directive.page import="java.sql.*" />
2: <jsp:scriptlet>
3: try {
4: Class.forName("oracle.jdbc.driver.OracleDriver");
5: Connection con = DriverManager.getConnection("jdbcracleci:@xe","hr","hr");

KINDLY HELP.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you using the JSP XML document format in your JSP?
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
learnt it from [URL=http://www.ibm.com/developerworks/java/library/j-webdata/
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JSP document format is not suitable for hand coding. It is primarily intended for the container to use as an intermediary representation of a page, or for when JSP pages are autogenerated from code where a DOM can be built and serialized.

I'd strongly suggest just using the "normal" JSP syntax. Trying to use the document sytnax will just yield a frustrating series of errors trying to get the very strict markup just right.
 
Anand Shrivastava
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tell me exactly how it should be done. I am very new to jsp and this is my first jsp.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66184
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to find a good book or tutorial on JSP. One that covers JSP 2.0.

You should probably also read this article to make sure you understand what JSP is fomr the start.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!