我的jsp页面一运行提示一下错误,找来找去都没有发现try,out的问题,但是编译器提示jsp第一行“<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" errorPage=""%>”有错。错误如下:
Error#:200:'.'expected
Error#:212:'catch' wihthout 'try'
Error#:209: 'try' without 'catch'or'finally'
Error#:200:'}'expected
大侠们给点建议吧,以前有没有遇到这种情况?
菜鸟谢谢各位了

解决方案 »

  1.   

    这是我页面的代码 先贴上
    <%@ page contentType="text/html; charset=GB2312"%>
    <%@ page import="metamanager.Login" %>
    <%!//处理字符串的方法
    public String codeString(String s)
     {
      String str=s;
      try{ byte b[]=str.getBytes("ISO-8859-1");
           str=new String(b);
       return str;
      }
      catch(Exception e)
      {
       return str;}
     }
    %>
    <html>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <head>
    <META content="MSHTML 6.00.2900.2802" name=GENERATOR><LINK
    href="images/count.css" type=text/css rel=stylesheet>
    <title>
    userLogin
    </title>
    </head>
    <script Language="JavaScript">function isspacestring(mystring)
    { var istring=mystring;
      var temp,i,strlen;
      temp=true;
      strlen=istring.length;
      for (i=0;i<strlen;i++)
      {
        if ((istring.substring(i,i+1)!=" ")&(temp))
         { temp=false;  }
      }
     return temp;
    }function firstisspace(mystring)
    { var istring=mystring;
      var temp,i,strlen;
      temp=false;
        if (istring.substring(0,1)==" ")
         { temp=true;  }
     return temp;
    }function check_input(theForm)
    {   if ((theForm.username.value == "")|(firstisspace(theForm.username.value)))
      {
        alert("请输入用户名.不能以空格开头");
        theForm.username.focus();
        return (false);
      }  if ((theForm.password.value == "")|(isspacestring(theForm.password.value)))
      {
        alert("请输入密码.");
        theForm.password.focus();
        return (false);
      }
    }
    </script>
    <body leftMargin=0 topMargin=0 rightMargin=0>
          <META content="Microsoft FrontPage 4.0" name=GENERATOR><LINK
          href="images/count.css" type=text/css rel=stylesheet><FORM action=login.jsp method=post onsubmit="return check_input(this)">
    <table border="0" align="center" cellpadding="0"  cellSpacing=0 width=633 bgColor=#c8dbea #008698?>  <tr>
        <td bgcolor="#FFFFFF">
          <tr>
    <td><img src="images/meheader_lg.gif" width="600" height="60" border="0" ></td>
     </tr>
         <tr>
            <td >
     <TABLE   align="center" cellSpacing=0 width=276 bgColor=#c8dbea #008698?>
     <tr><td>
     用户:
     </td>
     <td>
       <div align="left"><INPUT name=logname class="s01" size=16 maxLength=20></div>
     </td></tr>
         <tr>
     <td>密码:
     </td>
     <td><div align="left"><INPUT name=password type=password class="s01" size=16 maxLength=20></div>
     </td>
     </tr>
     <tr>
           <td width="85" height="37">
              <input name=submit type=submit value="登 陆">
           </td>
       <td width="278"> <input name=submit1 type=reset id="submit1" value="取 消"></td>
          </tr>
        </TABLE>
    </td>
       </tr>
    </table>
    </FORM>
    <jsp:useBean id="login" class="Login" scope="session"></jsp:useBean>
    <%//提交信息后,验证信息是否正确
      String message="",logname="",password="";
      if(!(session.isNew()))
      {logname=request.getParameter("logname");
         if(logname==null)
     {logname="";}
     logname=codeString(logname);
     password=request.getParameter("password");
     if(password==null)
     {password="";}
     password=codeString(password);
    %>
    <%
    if(!(logname.equals("")))
    {
    %>
    <jsp:setProperty name="login" property="logname" value="<%=logname%>"/>
    <jsp:setProperty name="login" property="password" value="<%=password%>"/>
    <%
      message=login.getMessage();
      if(message==null)
      {
      message="";
      }
    }
    %>
    <% if(!(session.isNew()))
       {  if(message.equals("ok"))
          {
      String str=response.encodeURL("index.htm");
      response.sendRedirect(str);
      }
           else
       {out.print(message);}
        }%>
    </body>
    </html>
      

  2.   

    if(!(session.isNew()))
      { ...后面的 } 呢?在哪匹配? LZ 再认真看看代码,这些都是小问题
      

  3.   

    if(!(session.isNew()))
      {logname=request.getParameter("logname");
         if(logname==null)无返回括号
      

  4.   

    <jsp:useBean id="login" class="Login" scope="session"></jsp:useBean>
    <%//提交信息后,验证信息是否正确
      String message="",logname="",password="";
      if(!(session.isNew())){
      logname=request.getParameter("logname");
         if(logname==null){
         logname="";
         }
     logname=codeString(logname);
     password=request.getParameter("password");
     if(password==null) {password="";}
     password=codeString(password);
    %>
    是的,这里的好像没有。