syntax error in JSP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: syntax error in JSP

  1. #1
    satish Guest

    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>






  2. #2
    Badri Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center