aspose file tools*
The moose likes JSP and the fly likes see my jsp error dscon$jsp.java [67:1] cannot resolve symbol  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "see my jsp error dscon$jsp.java [67:1] cannot resolve symbol  " Watch "see my jsp error dscon$jsp.java [67:1] cannot resolve symbol  " New topic
Author

see my jsp error dscon$jsp.java [67:1] cannot resolve symbol

muhammad fahim
Ranch Hand

Joined: Dec 17, 2006
Posts: 45
sir i want to use the datasource in my jsp page
i see tomcate help in connection pooling

then i set my server.xml and web.xml

server.xml
location = C:\Program Files\j2sdk_nb\netbeans3.5\tomcat406\conf\server.xml
code ==***
***********
- <Context path="/DBTest" docBase="DBTest" debug="5" reloadable="true" crossContext="true">
<Logger className="org.apache.catalina.logger.FileLogger" prefix="localhost_DBTest_log." suffix=".txt" timestamp="true" />
<Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" />
- <ResourceParams name="jdbc/myoracle">
- <parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
- <parameter>
<name>driverClassName</name>
<value>oracle.jdbc.OracleDriver</value>
</parameter>
- <parameter>
<name>url</name>
<value>jdbcracle:thin:@127.0.0.1:1521:aamir</value>
</parameter>
- <parameter>
<name>username</name>
<value>scott</value>
</parameter>
- <parameter>
<name>password</name>
<value>tiger</value>
</parameter>
- <parameter>
<name>maxActive</name>
<value>20</value>
</parameter>
- <parameter>
<name>maxIdle</name>
<value>10</value>
</parameter>
- <parameter>
<name>maxWait</name>
<value>-1</value>
</parameter>
</ResourceParams>
</Context>

*******

web.xml

where my all file and my project

location = F:\oraclewithjavaconn\WEB-INF\web.xml

code ==***
***********

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE web-app (View Source for full doctype...)>
- <resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

******

sir this is my jsp code for database instance in
F:\oraclewithjavaconn\conntest
*******

<HTML>
<%@ page import="java.sql.*,java.util.*" %>
<%
Context initContext = new InitialContext();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();
%>
<br>
TEST DONE!
</HTML>
*************

sir when i compli the page then system give me error

error*********

scon$jsp.java [67:1] cannot resolve symbol
symbol : class Context
location: class org.apache.jsp.dscon$jsp
Context initContext = new InitialContext();
^
dscon$jsp.java [67:1] cannot resolve symbol
symbol : class InitialContext
location: class org.apache.jsp.dscon$jsp
Context initContext = new InitialContext();
^
dscon$jsp.java [68:1] cannot resolve symbol
symbol : class Context
location: class org.apache.jsp.dscon$jsp
Context envContext = (Context)initContext.lookup("java:/comp/env");
^
dscon$jsp.java [68:1] cannot resolve symbol
symbol : class Context
location: class org.apache.jsp.dscon$jsp
Context envContext = (Context)initContext.lookup("java:/comp/env");
^
dscon$jsp.java [69:1] cannot resolve symbol
symbol : class DataSource
location: class org.apache.jsp.dscon$jsp
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
^
dscon$jsp.java [69:1] cannot resolve symbol
symbol : class DataSource
location: class org.apache.jsp.dscon$jsp
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
^
6 errors
Errors compiling dscon.
************

sir please give me idea how i use datasource in my jsp page

thank

aamir
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

The Context class is in the javax.naming package, which you're not imported in your code.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
muhammad fahim
Ranch Hand

Joined: Dec 17, 2006
Posts: 45
thank you for your reply

please guid me how i add Context class
give me location where i add Context class

how use javax.naming package
give me loation of javax.naming package

thank you

aamir
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

just import this package in page directive of your jsp page as you already import other packages.


muhammad fahim
Ranch Hand

Joined: Dec 17, 2006
Posts: 45
hi master

sir i add your give file but did not jsp page run

sir i not change in sever.xml and web.xml
some body give me idea i change in only Context.xml in META-INF folder

this is Context.xml code

<?xml version="1.0" encoding="UTF-8" ?>
<Context path="/dcp" privileged="true">
<Resource name="jdbc/postgres" auth="Container"
type=" javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbcracle:thin:@127.0.0.1:1521:aamir"
username="muhammad" password="mfa786" maxActive="1" maxIdle="0" maxWait="-1"/>
</Context>


*********
and this is my jsp code

<HTML>
<%@ page import="java.sql.*,java.util.*" %>
<%@ page import="javax.sql.DataSource" %>
<%@ page import="javax.naming.Context" %>
<%@ page import="javax.naming.InitialContext"%>

<%
Context initContext = new InitialContext();
DataSource ds = (DataSource)initContext.lookup("java:comp/env/jdbc/myOracleDataSource");
Connection conn = ds.getConnection();
%>

<br>
TEST DONE!
</HTML>

but sir jsp page give me error

javax.servlet.ServletException: Name jdbc is not bound in this Context


please give me idea how i run my jsp page

thank'
aamir
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

try this to be change in your jsp


hope it helps.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: see my jsp error dscon$jsp.java [67:1] cannot resolve symbol