my dog learned polymorphism*
The moose likes JSP and the fly likes error in jsp(please help) 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 jsp(please help)" Watch "error in jsp(please help)" New topic
Author

error in jsp(please help)

Namrata Kakkar
Greenhorn

Joined: Aug 24, 2009
Posts: 6
Hi i am writing a code in which i have to call one jsp page from another but as soon as the control gets transferred i get the error msg as:


Syntax error on token(s), misplaced construct(s)
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 19 in the jsp file: /second/process.jsp
Syntax error, insert "AssignmentOperator Expression" to complete Assignment
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 19 in the jsp file: /second/process.jsp
Syntax error, insert ";" to complete Statement
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 19 in the jsp file: /second/process.jsp
forward cannot be resolved
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 19 in the jsp file: /second/process.jsp
The operator / is undefined for the argument type(s) String, void
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 19 in the jsp file: /second/process.jsp
Syntax error on tokens, delete these tokens
16: if(rs.next()==false)
17: {
18:
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>


An error occurred at line: 22 in the jsp file: /second/process.jsp
Syntax error, insert "}" to complete Statement
19: <jsp:forward page="success.jsp"/>
20:
21: }
22: %>
23:
24: <%
25: else


An error occurred at line: 31 in the jsp file: /second/process.jsp
Syntax error, insert "Finally" to complete TryStatement
28: <jsp:forward page="fail.jsp"/>
29: <%
30: }
31: }
32: %>
33: <%catch(Exception e)
34: {


An error occurred at line: 32 in the jsp file: /second/process.jsp
Syntax error, insert "}" to complete Block
29: <%
30: }
31: }
32: %>
33: <%catch(Exception e)
34: {
35:


I am using MS-ACCESS AS DATABASE.

the jsp code is:


<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.io."%>
<%@ page import = "java.sql."%>


<%
String account=request.getParameter("ac");
String password=request.getParameter("pass");
String url="Jdbc:Odbc:Namrata";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select from database1 where Account="account"and Password="+password);
if(rs.next()==false)
{

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

}
%>

<%
else
{
%>
<jsp:forward page="fail.jsp"/>
<%
}
}
%>
<%catch(Exception e)
{

out.println("the exception is:"+e);
}
%>
Danish Araquei
Greenhorn

Joined: Jul 05, 2006
Posts: 19
please check your select query,it should be "select * from" instead of "select from"
Namrata Kakkar
Greenhorn

Joined: Aug 24, 2009
Posts: 6
No use as still its showing the same error
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16


In a scriptlet, you have to write Java code. Is the jsp:forward tag Java code ? No.
It looks like you did it properly for the "else" block.

You should even stay away from writing any scriptlet at all in your JSP.


[My Blog]
All roads lead to JavaRanch
Namrata Kakkar
Greenhorn

Joined: Aug 24, 2009
Posts: 6
I have tried in all the ways but still no use

if(rs.next()==false)
{
%>
<jsp:forward page="success.jsp"/>

<%

}
%>

<%

else
{
%>

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

<%
}
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16


I see too many double quotations. Use single quotations instead. You'll need some around Password too.
And keep in mind what Danish said earlier.
Namrata Kakkar
Greenhorn

Joined: Aug 24, 2009
Posts: 6
I have corrected everything as alleged by danish and you but still the problem persists.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

but still the problem persists.

Please post the latest error and the latest source. (please enclose the source inside "code" tags)
Namrata Kakkar
Greenhorn

Joined: Aug 24, 2009
Posts: 6
An error occurred at line: 30 in the jsp file: /second/process.jsp
Syntax error on token "else", delete this token
27:
28: <%
29:
30: else
31: {
32: %>
33:


An error occurred at line: 38 in the jsp file: /second/process.jsp
Syntax error, insert "Finally" to complete TryStatement
35:
36: <%
37: }
38: }
39: %>
40:
41: <%catch(Exception e)


An error occurred at line: 39 in the jsp file: /second/process.jsp
Syntax error, insert "}" to complete Block
36: <%
37: }
38: }
39: %>
40:
41: <%catch(Exception e)
42: {

Danish Araquei
Greenhorn

Joined: Jul 05, 2006
Posts: 19
Hi,

please modify your page in that way

<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page import="java.io.*"%>
<%@ page import="java.sql.*"%>


<%
String account=request.getParameter("ac");
String password=request.getParameter("pass");
String url="Jdbc:Odbc:Namrata";
String username="";
String pwd="";
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection(url,username,pwd);
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("select * from database1 where Account='"+account+"'and Password='"+password+"'");
if(rset.next())
{
%>
<jsp:forward page="welcome.jsp"/>
<%
}
else
{
%>
<jsp:forward page="welcome.jsp"/>
<%
}
}
catch(Exception e)
{
out.println("the exception is:"+e);
}
%>
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: error in jsp(please help)
 
Similar Threads
Error In JSP Page
error in jsp declaration
struts 1.2 begining
struts2.0+jsp error
org. apache. jasper. JasperException : Unable to compile class for JSP: