org.apache.jasper.JasperException: Unable to compile class for JSPNote: sun.tools.javac.Main has been deprecated.
work\localhost_8080%2Fexamples\_0005cjsp_0005cvalidate_0002ejspvalidate_jsp_0.java:76: Missing term.
session.setAttribute("username", password);
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2329
posted
0
The syntax of the JSP is obviously incorrect. Without seeing the source, there's nothing anyone here can do (short of pointing out that it's extremely confusing to store the contents of a field called "password" in an attribute called "username").
numan ahmad
Ranch Hand
Joined: Jan 27, 2011
Posts: 45
posted
0
Respected sir this is my code
please tell me what is wrong in it ?
<%@ page import="java.sql.*" %>
<%
String username=request.getParameter("name");
String password=request.getParameter("pass");
String qry="Select * from student where username='"+username+"'and password='"+password+"'";
//out.println(qry);
The main thing that is wrong is that you are putting Java code into the JSP. This is a bad practice that has been discredited for 10 years now, ever since the introduction of JSP 2 in 2002!
Time to update your JSP knowledge.
Java code should be performed in Java classes; not within JSPs.
ok sir but may you please tell me what is the mistake in this code ?
Tim Moores
Rancher
Joined: Sep 21, 2011
Posts: 2329
posted
0
Firstly, this code is wide open to SQL injection attacks. If you're running this code you're actually asking to be hacked - it's trivially easy for an attacker to delete your data.
Secondly, your parentheses are mismatched.
Thirdly, as Bear has already pointed out, don't put scriptlets in your JSPs.
Next, don't use the JDBC/ODBC bridge driver in web apps (or for anything, really). It's buggy and not thread-safe; using it in a web app means asking for trouble.
And lastly, mixing actions like a <jsp:forward> with scriptlet code is bound to cause problems, too. Either use JSTL, or use scriptlets, but not both.
numan ahmad
Ranch Hand
Joined: Jan 27, 2011
Posts: 45
posted
0
if i do not use JDBC/ODCB then sir what should i used for web application ?
You are getting a lot of wise advice on using ODBC and using Scriptlets in JSP - be sure to pay heed to what they are telling you. But, I think the root of your error might have something to do with having two opening braces ({) and only one closing brace (}) within your JSP Scriptlet. That might explain why it's unable to compile it.
OCPJP
"In preparing for battle I have always found that plans are useless, but planning is indispensable."
-- Dwight D. Eisenhower
Bear Bibeault
Author and opinionated walrus
Marshal