This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes error in executing the jsp  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "error in executing the jsp  " Watch "error in executing the jsp  " New topic
Author

error in executing the jsp

Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Hi guys
and sorry to all
in previous post only i asked my error
but its not my thread
thats why i am posting my quetion again in new thread

the code in validate.jsp
previously i got error in try and catch block
but now i am getting again another error
where to i change the code

i am getting the error like following

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: Unable to compile class for JSP

An error occurred at line: 9 in the jsp file: /validate1.jsp

Generated servlet error:
[javac] Compiling 1 source file

C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\honey\org\apache\jsp\validate1_jsp.java:16: illegal start of type
if(!isUserExists())
^



An error occurred at line: -1 in the jsp file: null

Generated servlet error:
C:\Program Files\Apache Software Foundation\Tomcat 5.0\work\Catalina\localhost\honey\org\apache\jsp\validate1_jsp.java:156: <identifier> expected
}
^
2 errors


org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:83)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:315)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:406)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:463)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:430)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:511)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:274)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:810)


note The full stack trace of the root cause is available in the Apache Tomcat/5.0.25 logs.


--------------------------------------------------------------------------------

Apache Tomcat/5.0.25


can any one tell where can i cahnge
thanks in advacne
Geeta

[BPSouther: Added code tags]
[ April 18, 2008: Message edited by: Ben Souther ]
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Hi Geeta,
Remove the exclamatory (!) in the scriplet.

<%! //remove here

if(!isUserExists())
{
try

Regards,
Kiran.
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Also check that your catch block is in caps.

your code has
Catch(Exception e)
{
}

It should be like this. In small letter..("c" is in caps for catch in your code)
catch(Exception e)

Regards,
Kiran.
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Hi Kiran

I deleted ! mark in scriptlet
again i am getting the same error and there is no problem in try and catch block

what to do
how can sole my problem
any another solution
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

You could try following modern accepted standards and not putting Java code in JSPS.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Previously i did like that only
but i am not getting where to write sccess.jsp and filure.jsp
thats why i moved java code in jsp
i dont have any idea how to write the code

will you tell me how to write that one
because this is must and should i have to do
please any one help in this
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Geeta Ravikanti:
...
i dont have any idea how to write the code

will you tell me how to write that one
because this is must and should i have to do
please any one help in this


This is probably a good time to step back from your project and work your way through either a good book on JSP and Servlets or a good web tutorial.
The folks at Javaranch are always happy to help out when someone gets stuck with a specific issue but we make a point of not doing people's work for them.

We do have many resources for the Java, Servlets, JSP beginner (Greenhorn as we call them). Check out our BunkHouse for listings and reviews on books, including plenty on JSP and Servlets. We also have a CodeBarn full of sample code. There are some pre-written servlet and JSP apps there that show how to do a lot of the things that people get stuck with. If you want more personalized help, we have the CattleDrive which is a class with people who can review your code and let you know when you're going astray.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
K Kiran Kumar
Ranch Hand

Joined: Jan 04, 2006
Posts: 109
Hi Geeta,
We can only show the way but you need to trace it out....
Last friday, I have come up with my suggestion at 5:02 PM and you bounced back immediately at 5.09 PM.
I too faced so many problems 2 years back when I started coding. I can understand your problem. I am not blaming you but you could have taken some more time to debug your code and could have come back. The best way to sort out any issue is first google out with the exceptions you get....

Which server are you using??

Regards,
Kiran.
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
i am using the tomcat server
sankar anbazhagan
Greenhorn

Joined: Apr 21, 2008
Posts: 2
what is the return type of the method isUserExists()?
dhwani mathur
Ranch Hand

Joined: May 08, 2007
Posts: 621
Hi Geeta


i will say you just take the java code from your
JSP and place it in a simple java class (say abc.java),
then try to compile that java class and figure out were
actualy code goes wrong and later execute it .
As you get a fully executable code i.e if it works ....just copy
the code (from inside the class) and place it in JSP
(since you want to try through JSP ),it may sure work.

SCJP(1.5),SCWCD(On the way...)
Dhwani:>Winning is not important but it is the only thing.
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
thanQ for the reply

previously i exceuted like that only
after that i moved to jsp
here i got some errors
now i solved my problem from the forum
But now i am getting the logical errors
when ever i am inserting the data(either new user,or existing user) its giving same msg
and its not storing the new user in data base

here my code is


validate.jsp


<%@ page import="java.sql.*" %>
<%@ page import="javax.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.util.*" %>
<%@ page contentType="text/html" %>

<html>
<body>

<%
String uname=(String)request.getParameter("uname");
String pwd=(String)request.getParameter("pwd");
String age=(String)request.getParameter("age");
String email=(String)request.getParameter("pwd");
int age1=Integer.parseInt(age);


if(!isUserExists())
{

try
{

%>
<h1><%=uname%></h1>
<h1><%=pwd%></h1>
<h1><%=age%></h1>
<h1><%=email%></h1>
<%

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe","SYSTEM","remora");
System.out.println("connceted----->"+con.getClass());


String vsql="insert into app_users values(?,?,?,?)";

PreparedStatement psmt=con.prepareStatement(vsql);


psmt.setString(1,uname);
psmt.setString(2, pwd);
psmt.setInt(3,age1);
psmt.setString(4,email);
psmt.executeUpdate();
con.close();
%>

<jsp:forward page="/success.jsp"/>
<%
}
catch(Exception e)
{
System.out.println("Exception"+e);
}
}
else
{
%>
<jsp:forward page="/failure.jsp"/>
<%
}
%>

<%!
public boolean isUserExists()
{

int count=0;
String uname="geeta";


try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con= DriverManager.getConnection("jdbcracle:thin:@localhost:1521:xe","SYSTEM","remora");

System.out.println("connceted----->"+con.getClass());

Statement stmt=con.createStatement();
String vsql="select count(1) from app_users where uname='"+uname+"'";

ResultSet rs=stmt.executeQuery(vsql);

while(rs.next())
{
count = rs.getInt(1);
}
con.close();
}
catch(Exception e)
{
System.out.println("Exception ..."+e);
}

if(count==0)
return false;

else
return true;
}
%>
</body>
</html>


this is the code to validate wheather user existed or not

can you find where was i did the mistake
how to change the code


Thanks and Regards
Geeta
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Geeta,
Welcome to JavaRanch!

In an effort to help everyone get the most from our forums, we've compiled a
list of tips for asking questions here. You can find the list in our
FAQ section here.
In particular please see:
UseRealWords

Abbreviations such as "u" or "ur" in
place of "you" and "you are" or "you're" confound language translation software making
it hard for our non-English speaking members to read your posts.
"thanQ" is not a word in the English language.


Another one that would really help is to use UBB code tags whenever you post code to the ranch. I've looked at this thread several times but moved on without actually reading the code because it's so long and unformatted.




Again, welcome to JavaRanch and good luck with your question.
-Ben
Geeta Ravikanti
Ranch Hand

Joined: Mar 26, 2008
Posts: 46
Sorry for those things
From next time on wards I will never try to repeat that mistakes
I dont know what is UBB code tags
how can I post the code


Regards
Geeta
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

If you look in my post, you'll see that "UBB Code Tags" is a link to a page that shows you how to use them.

You can always edit your previous posts by clicking on the icon.
 
jQuery in Action, 2nd edition
 
subject: error in executing the jsp
 
Similar Threads
uable to execute jsps
error in running the jsp
JSP - Oracle connectivity
getting errors in tomcat server
problem in jsp page