Menu

Jsp 2.0

Help
Bunty
2006-07-04
2012-10-09
  • Bunty

    Bunty - 2006-07-04

    hi !

    I have JSP 2.0 Tomcate 5.5.12 installed

    will DisplayTag work with this?

    Please Help

    Bunty

     
    • boske3

      boske3 - 2006-07-04

      Of course it will!
      Just try it. I work on Tomcat 5.5.9 and it goes great
      Greetings!

       
      • Bunty

        Bunty - 2006-07-04

        Thanks boske3 for ur reply

        Can u please help me in running my first example...here is the code Please HELP
        If any thing wrong please guide its very urgent for my final year project

        <%@ page language="java" import="java.sql.,java.util.,org.apache.commons.beanutils.,org.displaytag." %>
        <%@page contentType="text/html"%>
        <%@page pageEncoding="UTF-8"%>
        <%@ taglib uri="http://displaytag.sf.net" prefix="display" %>

        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        </head>
        <body>
        <%
        ArrayList rows1= null;

                try {
                    ResultSet rs;
                    Statement stmt;
                    Class.forName(&quot;com.mysql.jdbc.Driver&quot;);
                    out.println(&quot;Welcome To PetroFed&quot;);
                    Connection conn = DriverManager.getConnection(&quot;jdbc:mysql://localhost:3306/test?user=root&amp;password=passit&quot;);
        
                    String sql = &quot;SELECT * FROM master&quot;;
                    stmt = conn.createStatement();
                    rs = stmt.executeQuery(sql);
                    RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
        
                    rows1=(ArrayList)resultSet.getRows();
        
                    request.setAttribute(&quot;rows1&quot;,rows1);
        
                    rs=null;
                    stmt=null;
                } catch(Exception e) {
                    e.printStackTrace();
                }
        
        
                %&gt;
        
        
                          &lt;display:table name=&quot;rows1&quot; id=&quot;rows1&quot; export=&quot;true&quot; &gt;
                &lt;display:column property=&quot;email&quot; title=&quot;Email&quot; /&gt;
                &lt;display:column property=&quot;name&quot; /&gt;
                &lt;display:column property=&quot;company&quot; /&gt;
                &lt;display:column property=&quot;contact&quot; /&gt;
                &lt;display:column property=&quot;category&quot; /&gt;
                &lt;display:column property=&quot;edate&quot; /&gt;
                &lt;display:column property=&quot;desg&quot; /&gt;
                &lt;display:column property=&quot;others&quot; /&gt;
                &lt;/display:table&gt;
        
        
        &lt;/body&gt;
        

        </html>

         
        • boske3

          boske3 - 2006-07-05

          Hi
          First you must tell me what is wrong with this code?
          What type of error did you get?
          As i can see you want to display some columns from your table using
          displaytags ,am i right?
          What IDE are you use (NetBeans,Eclipse) or something else?

           
          • Bunty

            Bunty - 2006-07-05

            ya u r right m trying to display records of database table in Pagination form

            getting this error

            type Exception report

            message

            description The server encountered an internal error () that prevented it from fulfilling this request.

            exception

            org.apache.jasper.JasperException: Unable to compile class for JSP

            An error occurred at line: 42 in the jsp file: /pool.jsp
            Generated servlet error:
            D:\Documents and Settings\Gautam.netbeans\5.5beta\apache-tomcat-5.5.16_base\work\Catalina\localhost\ctags\org\apache\jsp\pool_jsp.java:116: rows1 is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
            java.lang.Object rows1 = null;
            ^
            1 error

            org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:510)
            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
            

            root cause

            org.apache.jasper.JasperException: Unable to compile class for JSP

            An error occurred at line: 42 in the jsp file: /pool.jsp
            Generated servlet error:
            D:\Documents and Settings\Gautam.netbeans\5.5beta\apache-tomcat-5.5.16_base\work\Catalina\localhost\ctags\org\apache\jsp\pool_jsp.java:116: rows1 is already defined in _jspService(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
            java.lang.Object rows1 = null;
            ^
            1 error

            org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:84)
            org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:328)
            org.apache.jasper.compiler.AntCompiler.generateClass(AntCompiler.java:249)
            org.apache.jasper.compiler.Compiler.compile(Compiler.java:297)
            org.apache.jasper.compiler.Compiler.compile(Compiler.java:276)
            org.apache.jasper.compiler.Compiler.compile(Compiler.java:264)
            org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:563)
            org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:303)
            org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
            org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
            javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
            org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
            
             
    • Bunty

      Bunty - 2006-07-05

      Using Netbeans 5.5

       
    • boske3

      boske3 - 2006-07-07

      Ah i see !
      Question for you?
      Did you include in your project all .jar files?If you not
      You must include next jar files in your project:
      commons-beanutils-1.7.0.jar
      commons-collections-3.1.jar
      commons-lang-2.1.jar
      commons-logging-1.0.4.jar
      displaytag-1.1.jar
      dsiplaytag-export-poi-1.1.jar
      itext-1.3.jar
      jstl-1.1.2.jar
      log4j-1.2.12.jar
      poi-2.5.1.jar
      standard-1.0.6.jar

      when you import those files in project delete code

      org.apache.commons.beanutils.*

      and you need this code for using dislpay tags:

      ....
      <%@taglib uri="http://displaytag.sf.net" prefix="display"%>
      ...

      Think it will work now

       
    • Bunty

      Bunty - 2006-07-06

      i want to display the content of my database usin DisplayTag Pagination...m using NetBeans5.5 with tomcat 5.5.16.

      Please Help....

      Following is my code....

      <jsp:scriptlet>
      List rows1= null;

      try {
      ResultSet rs;
      Statement stmt;
      Class.forName("com.mysql.jdbc.Driver");

      Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?user=root&amp;password=passit");

      String sql = "SELECT * FROM gc";
      stmt = conn.createStatement();
      rs = stmt.executeQuery(sql);
      RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);

      rows1=resultSet.getRows();
      request.setAttribute("rows2",rows1);

      String dd = resultSet.getName();

      out.println(dd);//printing name
      out.println(rows1);//printing content of rows

      rs=null;
      stmt=null;
      } catch(Exception e) {
      e.printStackTrace();
      }

      </jsp:scriptlet>

      When i run the above code it displays the following

      org.apache.commons.beanutils.RowSetDynaClass [org.apache.commons.beanutils.BasicDynaBean@1fa6d18, org.apache.commons.beanutils.BasicDynaBean@1049d3, org.apache.commons.beanutils.BasicDynaBean@15ed659, org.apache.commons.beanutils.BasicDynaBean@14a7a12, org.apache.commons.beanutils.BasicDynaBean@9444d1, org.apache.commons.beanutils.BasicDynaBean@32060c, org.apache.commons.beanutils.BasicDynaBean@2b323e, org.apache.commons.beanutils.BasicDynaBean@1efb4be, org.apache.commons.beanutils.BasicDynaBean@435a3a, org.apache.commons.beanutils.BasicDynaBean@1d8c528, org.apache.commons.beanutils.BasicDynaBean@77eaf8, org.apache.commons.beanutils.BasicDynaBean@e35bb7]

      When i add

      <display:table name="rows1" />

      it display nothing found to display.

      Please help what i do?

      BuntyIndia

       
      • boske3

        boske3 - 2006-07-06

        This code that you gave is little confuised.
        As i can se you have problem with your ResultSet.
        I use more simple JSTL tag for that.Are you familiar in that tags?
        Problem with Result Set is that you have more then one column you must put it in some kind of list or vector and then to display it.

        "When i add
        <display:table name="rows1" />
        it display nothing found to display. "

        you got this message when you table is empty.
        Check your table is it full or not?

         
        • Bunty

          Bunty - 2006-07-06

          Table is Full have 15 records....
          Can u please give me running code if u have..

          u can paste here or mail me at bunty.india[at]gmail.com

          Please help me

          Bunty

           

Log in to post a comment.

MongoDB Logo MongoDB