• Post Reply Bookmark Topic Watch Topic
  • New Topic

error in validateuer.jsp page

 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi;
I am developing jsp application for student feedback system. I am using MYSQL as backend. My theme is like:
1.each student will have username and password set by administrator.
2.once user log in particular system it will show various poll topic and accordingly he/she can poll or submit own view.
The validateuser.jsp page is shown below.
<%@ page language ="java" %>
<%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %>
<%
String userid=request.getParameter("userid");
String password=request.getParameter("pass");

InitialContext context = new InitialContext();
DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mynewdatabase");
Connection conn = ds.getConnection();
context.close();

Statement stmt=conn.createStatement();
ResultSet rs=stmt.executeQuery("select UserId from user where emailid='"+userid+"' and password='"+password+"'");
rs.next();
String UserID = rs.getString("UserId");
rs.close();
if (UserID==null )
{
out.println("Invalid User");
session.invalidate();
%>

<jsp:forward page="/AccessDenied.jsp" />

<%
}
else
{
out.println("Valid User");
}


%>
<jsp:forward page="/main.jsp" />


The error showing in the page:
HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /validateuser.jsp at line 8

5: String password=request.getParameter("pass");
6:
7: InitialContext context = new InitialContext();
8: DataSource ds = (DataSource) context.lookup("java:comp/env/jdbc/mynewdatabase");
9: Connection conn = ds.getConnection();
10: context.close();
11:


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.validateuser_jsp._jspService(validateuser_jsp.java:114)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
org.apache.naming.NamingContext.lookup(NamingContext.java:770)
and like

Apache Tomcat/6.0.16

kindly give guidelines for above.
waiting for your valuable suggestion.
thanks and regards
haresh
[ July 07, 2008: Message edited by: Harshal Gurav ]
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Post you context.xml file here !
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The context.xml is:
<?xml version="1.0" encoding="UTF-8"?>
<Context path="/student/index.jsp" docBase="student"
debug="5" reloadable="true" crossContext="true">
Resource name="jdbc/mynewdatabase" auth="Container" type="javax.sql.DataSource"
maxActive="100" maxIdle="30" maxWait="10000"
username="root" password="root123" driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/mynewdatabase?autoReconnect=true"/>
</Context>
Thanks and regards
Harshal
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can naybody help me?
Thanks
Harshal
 
Sagar Rohankar
Ranch Hand
Posts: 2907
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


If you "copy and paste" this xml, then this xml is not well formed ,

Replace your context.xml , with this code :



Try this,
 
Harshal Gurav
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It is not working?
Is any other solution?
regards
harshal
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65524
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please be sure to use UBB code tags when posting code to the forums. Unformatted code is extremely hard to read and many people that might be able to help you will just move along. Please read this for more information.

You can go back and change your post to add code tags by clicking the .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!