隐含变量是在_jspService中产生的,而变量和方法的声明在_jspService外面。所以你这个肯定不能成功,因为声明的时候,out隐含变量还没有定义,所以报错。

解决方案 »

  1.   

    同意楼上的
    你可以看看生成的java文件,就一幕了然了
    如果是tomcat,应该放在work下面
      

  2.   

    应该这样写cc.jsp中
    public class tt{
      public void aa(){
        out.println("swewdsdsdsdss");
      }
    }
    index.jsp中
    <%@ include file="cc.jsp" %>
    <%
    tt tt1=new tt();
    tt1.aa();
    %>
    说明:应该把aa这个方法定义在一个类(tt)中,然后在index.jsp文件里面定义tt类的一个对象(tt1),然后用tt1这个对象来调用tt类中的方法(aa),这样讲解希望你能明白。多看面向对象编程的书,
      

  3.   

    out是隐含对象,在JSP中可以直接使用,你可以这样
    cc.jsp
    <%!
    public String aa(){
    return "swewdsdsdsdss";
    } %>
    index.jsp中
    <%@ include file="cc.jsp" %>
    <%out.println(aa());%>
      

  4.   

    cc.jsp
    里要调数据库而且要写页面
    所以 JetKingLau(漫溪碧透)说得方法可能不行
    但 w_tao8029(小小剑) ( ) 的方法好像调试不过
      

  5.   

    JetKingLau(漫溪碧透)的方法肯定可行。你可以返回一个RecordSet对象,然后在主调页面里面写页面,这样就行了。
      

  6.   

    我得asp代码如下
    <!--#include file="Connections/database.asp" -->
    <% 
    '子层数据处理子程序 
    Sub ListSubPower(id,aCurrentID) 
      '打开隶属于上层 powerid 的所有子层数据信息 
      set rs_sub=Server.CreateObject("ADODB.Recordset") 
      rs_sub.Open "select * from tb_menu where fd_parent=" & cstr(id) & " order by fd_sort",conn,1,3    '列子层数据 
      out.println "<table width=""100%"" border=""0"" cellpadding=""1"" cellspacing=""0"">"
      do while not rs_sub.eof 
        '层次数表态变量递进累加 
        format_i=format_i+1     out.println "<tr>"
        out.println "<td width=""15"">"
        if rs_sub("fd_sn") = aCurrentID then
          out.println "<div align=""right""><img src=""res/nav_button_current.gif"" width=""10"" height=""15""></div>"
        else
          out.println "<div align=""right""><img src=""res/nav_button_hi.gif"" width=""10"" height=""15""></div>"
        end if
        out.println "</td>"
        out.println "<td>"
        '处理弹出新浏览器窗口的问题,如果想打开新窗口就把fd_target字段值设为1
        if rs_sub("fd_target") = 1 then
         out.println "<a href='" & rs_sub("fd_link") & "' target=""_blank"" class=""mymemu3"">" & rs_sub("fd_caption") & "</a>" 
        else
         out.println "<a href='" & rs_sub("fd_link") & "' class=""mymemu3"">" & rs_sub("fd_caption") & "</a>" 
        end if
        out.println "<br>" 
        out.println "</td>"
        out.println "</tr>"    out.println "<tr>"
        out.println "<td width=""15"">"
        out.println "</td>"
        out.println "<td>"
        '递归调用子程序本身,对子层数据进行逐渐处理 
        'ListSubPower(rs_sub("fd_sn"),aCurrentID) 
        out.println "</td>"
        out.println "</tr>"
        rs_sub.movenext 
      loop 
      out.println "</table>"  '层次数表态变量递退累减  
      format_i=format_i-1    '关闭子层数据集 
      rs_sub.close 
      set rs_sub=nothing  
    End subSub showmenu(aRootID,aParentID,aCurrentID)  '打开所有父层数据 
      set rs=Server.CreateObject("ADODB.Recordset") 
      rs.Open "select * from tb_menu where fd_parent = " & aRootID & "  order by fd_sort",conn,1,3   '层次数表态变量赋初值 
      format_i=1 
      '列表主程序段 
      out.println "<table width=""100%"" border=""0"" cellpadding=""0"" cellspacing=""0"">"
      do while not rs.eof 
        '打印父层数据信息 
        out.println "<tr>"
        out.println "<td>"
        if rs("fd_sn") = aParentID then
          out.println "<a href='" & rs("fd_link")  & "' class=""mymemu2hi"">" & rs("fd_caption") & "</a>" 
        else
        if rs("fd_target") = 1 then
         out.println "<a href='" & rs("fd_link")  & "' target=""_blank"" class=""mymemu2"">" & rs("fd_caption") & "</a>" 
         else
         out.println "<a href='" & rs("fd_link")  & "' class=""mymemu2"">" & rs("fd_caption") & "</a>" 
         end if
        end if
        out.println "</td>"
        out.println "</tr>"
        '子程序调用,子层数据处理 
        out.println "<tr>"
        out.println "<td>"
        if rs("fd_sn") = aParentID then 
          Call ListSubPower(rs("fd_sn"),aCurrentID) 
        else
          'Call ListSubPower(rs("fd_sn")) 
        end if
        out.println "</td>"
        out.println "</tr>"    out.println "<tr>"
        out.println "<td height=""6"">"
        out.println "<img src=""res/nav_left_line_eugene.gif"" width=""138"" height=""1"">"
        out.println "</td>"
        out.println "</tr>"    rs.movenext 
      loop   out.println "</table>"
      '关闭父层数据集 
      rs.close 
      set rs=nothing 
      'put a feedback link
        out.println "<tr>"
        out.println "<td align='left' height='16'>"
    out.println "<a href='system_feedback_new.asp' class=""mymemu2"">Feedback/Change request on eHR</a>" 
        out.println "</td>"
        out.println "</tr>"
        out.println "<tr>"
        out.println "<td height=""6"">"
        out.println "<img src=""res/nav_left_line_eugene.gif"" width=""138"" height=""1"">"
        out.println "</td>"
        out.println "</tr>"  'put login and logout link
       if Session("MM_Username") = "" then
         out.println "<tr>"
         out.println "<td align='right' height='16' bgcolor='#6699cc'>"
    out.println "<a href='login.asp' class=""mymemu2"">Login</a>" 
         out.println "</td>"
         out.println "</tr>"
        else
         if Session("MM_Assistant") then
         out.println "<tr>"
         'out.println "<td align='right' height='16' bgcolor='#6699cc'>"
         out.println "<td align='right' height='16'>"
    out.println "<a href='system_select_boss.asp' class=""mymemu2"">Act for my boss</a>" 
         out.println "</td>"
         out.println "</tr>"
         end if
         out.println "<tr>"
         out.println "<td align='left' height='16'>"
    out.println "Current Logon User:"
         out.println "</td>"
         out.println "</tr>"     out.println "<tr>"
         out.println "<td class='formaltext' align='right' height='16'>"
    out.println Session("MM_Username")
         out.println "</td>"
         out.println "</tr>"     out.println "<tr>"
         out.println "<td align='right' height='16' bgcolor='#6699cc'>"
    out.println "<a href='login.asp' class=""mymemu2"">Logout</a>" 
         out.println "</td>"
         out.println "</tr>"
        end ifEnd Sub%> 
    好多页面通过参数调用它,怎么写成jsp文件
      

  7.   

    只说明方法就行
    我不知道使用servlet还是javabean还是在另页面写方法就像上面说得