• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

error in jsp(please help)

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
%>
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
please check your select query,it should be "select * from" instead of "select from"
 
Namrata Kakkar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
No use as still its showing the same error
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Namrata Kakkar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have corrected everything as alleged by danish and you but still the problem persists.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

but still the problem persists.


Please post the latest error and the latest source. (please enclose the source inside "code" tags)
 
Namrata Kakkar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
%>
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic