• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error in executing the jsp

 
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Geeta,
Remove the exclamatory (!) in the scriplet.

<%! //remove here

if(!isUserExists())
{
try

Regards,
Kiran.
 
K Kiran Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You could try following modern accepted standards and not putting Java code in JSPS.
 
Geeta Ravikanti
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
K Kiran Kumar
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am using the tomcat server
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the return type of the method isUserExists()?
 
Ranch Hand
Posts: 621
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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("jdbc:oracle: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("jdbc:oracle: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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 46
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic