-
syntax error in JSP
could anyone please tell me the syntax error in the follwoing JSP
..i am getting the error
--------------------------------------------------------------------
Error 500
An error has occured while processing request:http://pc27/logincheck.jsp
Message:Server caught unhandled exception from servlet [jsp]
Target Servlet: jsp
StackTrace:
--------------------------------------------------------------------------------
Root Error-1: C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:70:
'}' expected. ResultSet rs; ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:74:
Statement expected. public void logincheck() ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:90:
Type expected. _static_data_0.writeChars(726, 14, out); ^ 3 errors
com.ibm.servlet.jsp.http.pagecompile.PageCompileException: C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:70:
'}' expected. ResultSet rs; ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:74:
Statement expected. public void logincheck() ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:90:
Type expected. _static_data_0.writeChars(726, 14, out); ^ 3 errors at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.javaToClass(PageCompileServlet.jav a:1386)
at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.compileAndLoadServlet(PageCompileS ervlet.java:585)
-----------------------------------------------------------------
<html>
<body>
<h3> First JSP Example </h3>
<%@ import="java.util.*, java.sql.*, javax.servlet.*, javax.servlet.http.*,
java.io.* " session="true" isThreadSafe="true" %>
<%!
Connection con ;
Statement stmt ;
PreparedStatement pst ;
ResultSet rs;
public void logincheck()
{
try{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
con = DriverManager.getConnection("jdbc:db2:sample", "webs",
"websdba");
}
catch(Exception e) { e.printStackTrace(); }
}
%>
<%= "driver loaded and connection is created" %>
<br>
<%
try
{
String str_login = request.getParameter("MEMLOGIN");
String str_pwd = request.getParameter("MEMPWD");
pst = con.prepareStatement("select * from MEMTABLE
where MEMUSERNAME = ? and MEMUSERPWD = ?");
pst.setString(1, str_login);
pst.setString(2, str_pwd);
rs = pst.executeQuery();
if(rs.next())
{
response.sendRedirect("http://pc27/login.html")
;
}
else
{
response.sendRedirect("http://pc27/login.html")
;
}
}
catch(Exception e) {e.printStackTrace() ;
%>
</br>
</body>
</html>
-
Re: syntax error in JSP
closing brace (" } " ) is missing in ur code after the catch block. here's
the corrected one.
<%!
Connection con ;
Statement stmt ;
PreparedStatement pst ;
ResultSet rs;
public void logincheck()
{
try{
Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
con = DriverManager.getConnection("jdbc:db2:sample", "webs",
"websdba");
}
catch(Exception e) { e.printStackTrace(); }
}
} // This was the one missing
%>
--Badri.
"satish" <satish_141@yahoo.com> wrote:
>
>could anyone please tell me the syntax error in the follwoing JSP
>
>..i am getting the error
>
>--------------------------------------------------------------------
>Error 500
>An error has occured while processing request:http://pc27/logincheck.jsp
>Message:Server caught unhandled exception from servlet [jsp]
>Target Servlet: jsp
>StackTrace:
>--------------------------------------------------------------------------------
>Root Error-1: C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:70:
>'}' expected. ResultSet rs; ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:74:
>Statement expected. public void logincheck() ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:90:
>Type expected. _static_data_0.writeChars(726, 14, out); ^ 3 errors
>com.ibm.servlet.jsp.http.pagecompile.PageCompileException: C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:70:
>'}' expected. ResultSet rs; ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:74:
>Statement expected. public void logincheck() ^ C:\WebSphere\AppServer\temp\default_host\default_app\pagecompile\_logincheck_xjsp.java:90:
>Type expected. _static_data_0.writeChars(726, 14, out); ^ 3 errors at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.javaToClass(PageCompileServlet.jav a:1386)
>at com.ibm.servlet.jsp.http.pagecompile.PageCompileServlet.compileAndLoadServlet(PageCompileS ervlet.java:585)
>-----------------------------------------------------------------
>
>
>
> <html>
> <body>
>
><h3> First JSP Example </h3>
>
> <%@ import="java.util.*, java.sql.*, javax.servlet.*, javax.servlet.http.*,
> java.io.* " session="true" isThreadSafe="true" %>
>
>
>
> <%!
>
> Connection con ;
> Statement stmt ;
> PreparedStatement pst ;
> ResultSet rs;
>
>
>
> public void logincheck()
> {
>
> try{
>
> Class.forName("COM.ibm.db2.jdbc.app.DB2Driver");
> con = DriverManager.getConnection("jdbc:db2:sample", "webs",
>"websdba");
>
> }
>
> catch(Exception e) { e.printStackTrace(); }
>
> }
>
> %>
>
>
> <%= "driver loaded and connection is created" %>
>
> <br>
>
><%
>
> try
> {
>
> String str_login = request.getParameter("MEMLOGIN");
> String str_pwd = request.getParameter("MEMPWD");
>
>
> pst = con.prepareStatement("select * from MEMTABLE
>where MEMUSERNAME = ? and MEMUSERPWD = ?");
>
> pst.setString(1, str_login);
> pst.setString(2, str_pwd);
>
> rs = pst.executeQuery();
>
> if(rs.next())
> {
> response.sendRedirect("http://pc27/login.html")
> ;
> }
>
> else
> {
> response.sendRedirect("http://pc27/login.html")
> ;
> }
>
> }
>
> catch(Exception e) {e.printStackTrace() ;
>
>%>
>
> </br>
>
>
></body>
> </html>
>
>
>
>
>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks