<%@ page contentType="text/html;charset=gb2312" import="java.io.*"%>
<%@ page import="java.util.*"%>
<html>
<head>
<title>向文件内写入数据</title></head>
<body>
<center>
<%
   
   String ss="<html><head><script language='JavaScript'>function openwindow(){open('hm_26.html','窗口标题','toolbars=0,scrollbars=0,location=0,statusbars=0,
   menubars=0,resizable=0,width=650,height=150');}
   </script></head><body onLoad='openwindow()'><h2>打开广告窗口</h2></body></html>";
   try{
    FileOutputStream fos=new FileOutputStream("c://Tomcat 5.5//webapps//ROOT//JSP//file6.txt");
ObjectOutputStream oos=new ObjectOutStream(fos);
oos.writeObject(new Date());
oos.writeObject(ss);
oos.write.close();
}
  catch(IOException e){
    out.println(e);
}
 try{
    FileInputStream fis=new FileInputStream("c://Tomcat 5.5//webapps//ROOT//JSP//file6.txt");
ObjectInputStream ois=new ObjectInputStream(fis);
Date d=(Date)ois.readObject();
out.println("时间是"+d.getHours()+"点");
String s=(String)ois.readObject();
out.println(s);
ois.close();
}
 catch(IOException ee){
   out.println(ee);
   }
   %>
   </center>
   </body></html>
   
   总提示:"String literal is not properly closed by a double-quote"和"Syntax error on token "catch", Identifier expected”
但就是改不对,已经烦了一上午了。大家帮帮忙了。谢谢了!

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【gjk11】截止到2008-07-01 13:48:29的历史汇总数据(不包括此帖):
    发帖数:9                  发帖分:250                
    结贴数:8                  结贴分:220                
    未结数:1                  未结分:30                 
    结贴率:88.89 %            结分率:88.00 %            
    楼主加油
      

  2.   


     String ss=" <html> <head> <script language='JavaScript'>function openwindow(){open('hm_26.html','窗口标题','toolbars=0,scrollbars=0,location=0,statusbars=0, 
      menubars=0,resizable=0,width=650,height=150');} 
      </script> </head> <body onLoad='openwindow()'> <h2>打开广告窗口 </h2> </body> </html>"; 
    换行的地方应该用+联接。
    比如: String ss="aaa"
            +"bbb";要么就不要换行 。
      

  3.   

    LS的说的正确!java换行的string必须用+号连接
      

  4.   

            StringBuffer buffer = new StringBuffer();
            buffer.append("");
            ...
            String ss = buffer.toString();
      

  5.   

    String ss = " <html> <head> <script language='JavaScript'>"
          + "function openwindow(){"
          + "open('hm_26.html','窗口标题','toolbars=0,scrollbars=0,location=0,statusbars=0, menubars=0,resizable=0,width=650,height=150');}"
          + "</script> </head> <body onLoad='openwindow()'> <h2>打开广告窗口 </h2> </body> </html>";这样就可以了
      

  6.   

    这样<%@ page contentType="text/html;charset=gb2312" import="java.io.*"%>
    <%@ page import="java.util.*"%>
    <html>
    <head>
    <title>向文件内写入数据</title>
    </head>
    <body>
    <center>
    <%
    String ss = " <html> <head> <script language='JavaScript'>"
    + "function openwindow(){open('hm_26.html','窗口标题','toolbars=0,"
    + "scrollbars=0,location=0,statusbars=0,menubars=0,resizable=0,"
    +"width=650,height=150');} </script> </head> <body onLoad='"
    +"openwindow()'> <h2>打开广告窗口 </h2> </body> </html>";
    try {
    FileOutputStream fos = new FileOutputStream(
    "c://Tomcat 5.5//webapps//ROOT//JSP//file6.txt");
    ObjectOutputStream oos = new ObjectOutputStream(fos);
    oos.writeObject(new Date());
    oos.writeObject(ss);
    oos.close();
    } catch (IOException e) {
    out.println(e);
    }
    try {
    FileInputStream fis = new FileInputStream(
    "c://Tomcat 5.5//webapps//ROOT//JSP//file6.txt");
    ObjectInputStream ois = new ObjectInputStream(fis);
    Date d = (Date) ois.readObject();
    out.println("时间是" + d.getHours() + "点");
    String s = (String) ois.readObject();
    out.println(s);
    ois.close();
    } catch (IOException ee) {
    out.println(ee);
    }
    %>
    </center>
    </body>
    </html>