aspose file tools
The moose likes JSP and the fly likes  i am using server.xml and web.xml but jsp  give me error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » JSP
Bookmark " i am using server.xml and web.xml but jsp  give me error " Watch " i am using server.xml and web.xml but jsp  give me error " New topic

i am using server.xml and web.xml but jsp give me error

muhammad fahim
Ranch Hand

Joined: Dec 17, 2006
Posts: 45
sir i am using tomcate guidline see link

see my xml file =============
C:\Program Files\netbeans-5.5\enterprise3\apache-tomcat-5.5.17\conf\server.xml


- <Context path="/zooapp" docBase="DBTest" debug="5" reloadable="true" crossContext="true">
- <!--
maxActive: Maximum number of dB connections in pool. Make sure you
configure your mysqld max_connections large enough to handle
all of your db connections. Set to 0 for no limit.

- <!--
maxIdle: Maximum number of idle dB connections to retain in pool.
Set to -1 for no limit. See also the DBCP documentation on this
and the minEvictableIdleTimeMillis configuration parameter.

- <!--
maxWait: Maximum time to wait for a dB connection to become available
in ms, in this example 10 seconds. An Exception is thrown if
this timeout is exceeded. Set to -1 to wait indefinitely.

- <!-- username and password: MySQL dB username and password for dB connections
- <!--
driverClassName: Class name for the old mm.mysql JDBC driver is - we recommend using Connector/J though.
Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.

- <!--
url: The JDBC connection url for connecting to your MySQL dB.
The autoReconnect=true argument to the url makes sure that the
mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
connection. mysqld by default closes idle connections after 8 hours.

<Resource name="jdbc/myoracle" auth="Container" type="javax.sql.DataSource" driverClassName="oracle.jdbc.OracleDriver" url="jdbcracle:thin:@" username="muhammad" password="mfa786" maxActive="20" maxIdle="10" maxWait="-1" />


my web.xml ======

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<servlet-name>Faces Servlet</servlet-name>
<servlet-name>Faces Servlet</servlet-name>

<description>Oracle Datasource example</description>



my jsp index.jsp page ======

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
<%@taglib uri="" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"


<%@ 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();
Context envContext = (Context)initContext.lookup("java:/comp/env");
DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle");
Connection conn = ds.getConnection();

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>

<h1>JSP Page</h1>
JavaServer Faces Welcome Page

This example uses JSTL, uncomment the taglib directive above.
To test, display the page like this: index.jsp?sayHello=true&name=Murphy
<c:if test="${param.sayHello}">
<!-- Let's welcome the user ${} -->
Hello ${}!


this is error ===

type Exception report


description The server encountered an internal error () that prevented it from fulfilling this request.


org.apache.jasper.JasperException: Exception in JSP: /index.jsp:25

22: <%
23: Context initContext = new InitialContext();
24: Context envContext = (Context)initContext.lookup("java:/comp/env");
25: DataSource ds = (DataSource)envContext.lookup("jdbc/myoracle"); ====>>> this line give me error
26: Connection conn = ds.getConnection(); ====>>> this line give me error
27: %>
28: <%-->


root cause

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

any other method can i use for define recordset in one page and use multy page

please give me idea how i use datasource or one recordset in multy jsp page
Joan Horta Tosas
Ranch Hand

Joined: Feb 01, 2007
Posts: 59
Try removing this line
Have you tried LearnNowOnline?
subject: i am using server.xml and web.xml but jsp give me error