This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes JSP and the fly likes Internal Servlet Error: Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Internal Servlet Error:" Watch "Internal Servlet Error:" New topic
Author

Internal Servlet Error:

numan ahmad
Ranch Hand

Joined: Jan 27, 2011
Posts: 49
hay to all...
i am new in jsp and making login form and i got an error please tell me how can i remove that error...

Internal Servlet Error:

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: 2408
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: 49
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);

String driver="sun.jdbc.odbc.JdbcOdbcDriver";

Class.forName(driver);
java.sql.Connection con=DriverManager.getConnection("Jdbc:Odbc:LHR");
java.sql.Statement stmt=con.createStatement();
java.sql.ResultSet rs=stmt.executeQuery("qry");
if (rs.next())
{
session.setAttribute("username", password);

<jsp:forward page="about.html">
</jsp:forward>
else {
out.println("Invalid username & password");
}
%>
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60756
    
  65

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
numan ahmad
Ranch Hand

Joined: Jan 27, 2011
Posts: 49
ok sir but may you please tell me what is the mistake in this code ?
Tim Moores
Rancher

Joined: Sep 21, 2011
Posts: 2408
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: 49
if i do not use JDBC/ODCB then sir what should i used for web application ?
Pete Nelson
Ranch Hand

Joined: Aug 30, 2010
Posts: 147

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 ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60756
    
  65

That and the fact that he's plunking JSP actions right into the middle of the scriptlets.

This sort of mixed syntax nightmare is just one of the very many reasons that scriptlets are discredited.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Internal Servlet Error:
 
Similar Threads
Bootstrap unable to get a t3 connection to localhost/127.0.0.1
Class not found exception
Error in init() servlet methode
"Internal Servlet Error:" and "Root cause:" ?
initialization problem