JSP也可以有JAVASCRIPT脚本,但是你应该明白JSP的主要应用领域!!!

解决方案 »

  1.   

    <script language ="JavaScript">
    function f()
    {
      alert("sssss");
    }
    </script>
    <input type=button value="button" onclick="f()">
      

  2.   

    asp: response.write "<script>alert('xxx'!);history.go(-1);</script>"(弹出对话框,并返回
    用jsp实现如下:
     
    out.print("<script>alert('xxx');history.go(-1);</script>");
      

  3.   

    我有看书呀,我买了本JSP开发应用详解!但确实有些地方不明白嘛我并没有用啊,只是想比较看一下区别!再问一个插入时间字段的变量
    如果是ASP
    nowtime=now()
    insert into 表名(时间字段)('"&nowtime&"')
    如果是JSP
    不是不是这样
    头文件有包含(import="java.util,*")
    nowtime = new Date( )
    insert into 表名(时间字段)('"+nowtime+"')这样对不?!
      

  4.   

    String u="jdbc:odbc:date";
     Connection con=DriverManager.getConnection(u);
      Statement s=con.createStatement
      String q="select id,dept,position,number,request,salary,creatime from zhaopin";
      ResultSet rs=s.executeQuery(q);
       if(!rs.next())//等于if rs.eof then   xxxxxxxxx(数据库中,如果找不到记录)
       {
          response.sendRedirect("pagename.jsp");//等于asp: response.write 
          return;
        }
      

  5.   

    谢谢小菜鸟,还有时间问题呢
    我这样写,有错误<%@ include file="dbcon.inc" %>
    <%@ page contentType="text/html;charset=gb2312" import="java.util.*" %>
    <html>
    <head><title>数据库测试</title></head>
    <body>
    <%
       Date now = new Date ( );
       String nowTime = now.toLocaleString ( );
       Class.forName( CLASSFORNAME ).newInstance( );
       Connection con= DriverManager.getConnection( SERVANDDB,USER,PWD );
       Statement statement = con.createStatement ( );
       String sql = "insert into [t3](name,logintime) values('ddr','"+nowTime+"')";
       statement.execute( sql );
       statement.close ( );
       con.close ( );
    %>
    </body>
    </html>错误:
    type Exception reportmessage description The server encountered an internal error () that prevented it from fulfilling this request.exception org.apache.jasper.JasperException: Unable to compile class for JSPAn error occurred at line: 6 in the jsp file: /3.jspGenerated servlet error:
        [javac] Compiling 1 source fileD:\Program Files\Tomcat\work\Catalina\localhost\myweb\org\apache\jsp\_3_jsp.java:72: reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match
       Date now = new Date ( );
       ^An error occurred at line: 6 in the jsp file: /3.jspGenerated servlet error:
    D:\Program Files\Tomcat\work\Catalina\localhost\myweb\org\apache\jsp\_3_jsp.java:72: reference to Date is ambiguous, both class java.util.Date in java.util and class java.sql.Date in java.sql match
       Date now = new Date ( );
                      ^An error occurred at line: 6 in the jsp file: /3.jspGenerated servlet error:
    Note: D:\Program Files\Tomcat\work\Catalina\localhost\myweb\org\apache\jsp\_3_jsp.java uses or overrides a deprecated API.
    Note: Recompile with -deprecation for details.
    2 errors
    org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
    org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
    org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:418)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:461)
    org.apache.jasper.compiler.Compiler.compile(Compiler.java:442)
    org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    note The full stack trace of the root cause is available in the Tomcat logs.
    --------------------------------------------------------------------------------Apache Tomcat/5.0.14
      

  6.   

    <%@ page import="java.sql.*" %>
      

  7.   

    连接数据库时应该加try块儿
    try
    {}
    catch
    {}
      

  8.   

    java.sql.*包在dbcon.inc里有了到底怎么会事啊