Jsp errot help!

i have 4 error after compling this files, cannot 1 help pls!
<%@ page import="java.io.*"%>
<%@ page import="java.util.zip.*"%>
<%@ page import="java.lang.Thread"%>
<%@ page import="java.net.URL"%>
<%@ page import="java.net.URLConnection"%>
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="java.util.StringTokenizer.*"%>
<%
class ThreadBase implements Runnable
int counter = 0;
public void run()
     try
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
     catch(ClassNotFoundException e)
          System.out.println(e);
     Connection c = DriverManager.getConnection("jdbc:odbc:MHuman");
     Statement s = c.createStatement();
          int x = 1;
          String x_str = "";
          do{
                    x_str = Integer.toString(x);
                    if (x==23) x_str = "X";
                    else if (x==24) x_str="Y";
               try
                    String sqlstr = "CREATE TABLE Chromosome"+x_str+" " +
                    "(ID number, HChr varchar (20), Hstart number, Hend number, MChr varchar (20), Mstart number, Mend number)";
                    System.out.println(sqlstr);
                    try { s.execute("Drop table Chromosome"+x_str+"");
               catch (Exception e) { };
               s.execute(sqlstr);
catch(SQLException e)
e.printStackTrace();
// Create BufferedReader object.
BufferedReader br = null;
try
          br = new BufferedReader(
          new FileReader("C:\\downloadChr\\mhuman\\chr"+x_str+".txt"));
catch(IOException e)
     System.out.println(e);
String line, ID, HChr, Hstart, Hend, MChr, Mstart, Mend, sql;
StringTokenizer st;
try
     cs();
     while ((line = br.readLine()) != null)
               st = new StringTokenizer(line, " ");
               ID = st.nextToken();
               HChr = st.nextToken();
               Hstart = st.nextToken();
               Hend = st.nextToken();
               MChr = st.nextToken();
               Mstart = st.nextToken();
               Mend = st.nextToken();
               if (!MChr.startsWith("chrNA"))
                    if (!MChr.startsWith("chrM"))
                         if (!MChr.startsWith("chrUn"))
                              if (!MChr.startsWith("chrFinished"))
                    sql = "INSERT INTO Chromosome"+x_str+" " +
                    "VALUES (" + ID + ", '" + HChr + "', " + Hstart + ", " + Hend + ", '" + MChr + "', " + Mstart + ", " + Mend + ")";
                    //System.out.println(sql);
                    s.executeUpdate(sql);
catch(IOException e)
System.out.println(e);
}while (x++ < 12);
     c.close();
     private void cs()
          int a = counter;
          a++;
          counter = a;
          System.out.println("Thread is running with Chr " + counter);
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL3_jsp.java:74: unreported exception java.sql.SQLException; must be caught or declared to be thrown
An error occurred at line: 9 in the jsp file: /jsp/HMC/HTML/testDL3.jsp
Generated servlet error:
     Connection c = DriverManager.getConnection("jdbc:odbc:MHuman");
^
An error occurred at line: 9 in the jsp file: /jsp/HMC/HTML/testDL3.jsp
Generated servlet error:
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL3_jsp.java:76: unreported exception java.sql.SQLException; must be caught or declared to be thrown
     Statement s = c.createStatement(); ^
An error occurred at line: 9 in the jsp file: /jsp/HMC/HTML/testDL3.jsp
Generated servlet error:
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL3_jsp.java:139: unreported exception java.sql.SQLException; must be caught or declared to be thrown
                    s.executeUpdate(sql);
^
An error occurred at line: 9 in the jsp file: /jsp/HMC/HTML/testDL3.jsp
Generated servlet error:
C:\Program Files\Tomcat 4.1\work\Standalone\localhost\examples\jsp\HMC\HTML\testDL3_jsp.java:153: unreported exception java.sql.SQLException; must be caught or declared to be thrown
     c.close();
^
4 errors

Your Connection object and Statement object is written outside try{}.
Put all your code inside try{}.
Hope this will solve your problem.

Similar Messages

  • Best way to create, modify, XML with JSP ?  HELP

    Hi friends,
    As i am new to XML,
    I know there are two APIs used for XML processing, i want to know as a begineer level, which API
    is easy and good to implement XML with JSP.
    1) SAX
    2) DOM
    i want to make a log file in XML, so on web page it will be displayed on HTML form through XSL.
    Since there is good tutorial on http://www.w3schools.com/dom
    but i think its HTML dom
    I want XML procession through JAVA CODE , what should i use ? and give some good tutorials on XML DOM
    that is used with JAVA / JSP.
    HELP.
    Edited by: Ghanshyam on Sep 19, 2007 3:24 PM

    Well what i think is you gonna checkout with your requirements before implementing any of the popular XML parsing mechnisms.
    If you are intrested in faster processing @sacrifising a gud amount of your Memory,DOM is the one which you are looking for.
    If you are instrested in Managing your memory and but if you are ok with sacrifising speed SAX is the best solution.it works on what is called a push technology.
    and if you think either way you might have to look towards a pull parser which is StAX (Streaming API for XML Parsing)
    it'd be a gr8 idea if you can go through the below article which explians about each of the parsing mechanisms
    http://www.stylusstudio.com/xml/parser.html#*
    coming back to helpful resources as far java is concern checkout the below link which might be of some help.
    and the main thing is that all of these parser there is a defined specification you might find implementations of different vendors on this.
    eg:Sun Provides one with JDK itself,same as IBM provides one,oracle does the same & so on...
    your first task would be to focus on one such implementation which can cater your requirements.
    DOM:*
    Basic Parsing Objects / Interfaces Involved while DOM parsing:
    http://www.w3.org/TR/DOM-Level-2-Core/java-binding.html
    Breif Overview & few important API details:
    http://www.developerlife.com/domintro/default.htm
    Simple Example:
    http://www.brics.dk/~amoeller/XML/programming/domexample.html
    Others:
    http://www.roseindia.net/xml/dom/
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPDOM.html#wp79994
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/1_read.html
    SAX:*
    http://www.javacommerce.com/displaypage.jsp?name=saxparser1.sql&id=18232
    http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/sax/index.htm
    http://java.sun.com/developer/Books/xmljava/ch03.pdf
    http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JAXPSAX.html#wp69937
    http://www.onjava.com/pub/a/onjava/excerpt/java_xslt_ch5/index.html?page=6
    StAX:*
    http://java.sun.com/webservices/docs/1.6/tutorial/doc/SJSXP2.html
    http://javaboutique.internet.com/tutorials/stax/
    http://today.java.net/pub/a/today/2006/07/20/introduction-to-stax.html
    Hope this might be of some help :)
    REGARDS,
    RaHuL
    http://weblogs.java.net/blog/spericas/archive/2006/04/sun_stax_parser.html

  • Problem with String in JSP! Help Me

    Hi all,
    i spent my whole day with this error. How can i solve it. I am trying to convert a string array to Integer array. The program is taking all the select input from the previous JSP page and then converting them into integer array for storing to database. i am catching them as request.getParameterValues(); but i found out that if i select 4 item from the menu it is storing in 8 array cells and the format is if you select 1 2 3 4 the it stores [1 null 2 null 3 null 4 null] i guessed that those are null values. so i have tried to select only 1 2 3 4 from the array and it is showing number format error on tomcat. here is the code guys. Please i am tired of it please help me. Thanks. SORRY I TRIED TO SEPARATE THE CODE BUT IT SEEMS LIKE THERE ARE SOME PROBLEM IN THE FORUM SETTINGS. so the code is:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <%@page import="java.io.*"%>
    <%@page import="java.sql.*"%>
    <%@page import="java.lang.String.*"%>
    <%@page import="java.lang.Character.*"%>
    <%@page import="java.util.*"%>
    <%@page import="java.text.*"%>
    <HTML>
    <HEAD>
    <TITLE> HR ADVANTAGE TIMESHEET </TITLE>
    </HEAD>
    <BODY>
    <%
    String emplno = request.getParameter("emplno");
    String date = request.getParameter("date");
    String proposal = request.getParameter("proposals");
    String network1 = request.getParameter("network");
    String suppassociates = request.getParameter("suppasso");
    String intmngt = request.getParameter("intmgt");
    String client[] = request.getParameterValues("client");
    String client1= request.getParameter("client1");
    String clientunit[] = request.getParameterValues("clientunit");
    String clientunit1=request.getParameter("clientunit1");
    boolean bool=true;
    int staffid = Integer.parseInt(emplno);
    int len=0;
    len=client.length;
    //String[] check_client = new String[len];
    //check_client=client;
    //int check_length=0;
    //check_length=check_client.length;
    //int unitlength=0;
    //unitlength=clientunit.length;
    int arr_length=0;
    arr_length=len-(len/2);
    int[] array = new int[arr_length];
    int j=0;
    j=arr_length;
    for (int i=0; i<len-1; i++)
    bool=true;
    if(client=="\0")
    bool=false;
         if(bool==true)
         array[arr_length-j]=Integer.parseInt(client[i]);
              j=j-1;
              if(j==0)
              break;
    %>
    </BODY>
    </HTML>
    The error is:
    org.apache.jasper.JasperException: For input string: ""
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:367)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
    root cause
    java.lang.NumberFormatException: For input string: ""
         java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
         java.lang.Integer.parseInt(Integer.java:489)
         java.lang.Integer.parseInt(Integer.java:518)
         org.apache.jsp.store_jsp._jspService(store_jsp.java:107)
         org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:320)
         org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:293)
         org.apache.jasper.servlet.JspServlet.service(JspServlet.java:240)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:856)

    what are you trying to test with client [ i ] == "\0"
    You sure you dont need to test against null ?

  • How to retrieve records from a database and display it in a jsp page.Help!!

    Hello everyone ! im very new to this forum.Please help me to solve my problem
    First i ll explain what is my requirement or needed.
    Actually in my web page i have text box to enter start date and end date
    and one list box to select the month .If user select or enter the dates in text box
    accordingly the data from ms access database has to display in a jsp page.
    Im using jsp and beans.
    I tried returning ResultSet from bean but i get nothing display in my web page
    instead it goes to error page (ErrorPage.jsp) which i handle in the jsp.
    I tried many things but nothing work out please help me to attain a perfect
    solution. I tried with my bean individually to check whether the result set has
    values but i got NullPointerException . But the values which i passed or
    available in the database.
    I dint get any reply for my last post please reply atleast to this.
    i get the date in the jsp page is by this way
    int Year=Integer.parseInt(request.getParameter("year"));
    int Month=Integer.parseInt(request.getParameter("month"));
    int Day=Integer.parseInt(request.getParameter("day"));
    String startdate=Day+"/"+Month+"/"+Year;
    int Year1=Integer.parseInt(request.getParameter("year1"));
    int Month1=Integer.parseInt(request.getParameter("month1"));
    int Day1=Integer.parseInt(request.getParameter("day1"));
    String enddate=Day1+"/"+Month1+"/"+Year1;But this to check my bean whether it return any result!
    public void databaseConnection(String MTName,String startDate,String endDate)
    try
             java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
            java.sql.Date sqlFromDate=new java.sql.Date(fromDate.getTime());
            java.sql.Date sqlTillDate=new java.sql.Date(tillDate.getTime());
              String query1="select MTName,Date,MTLineCount from Main where MTName='"+MTName+"'  and Date between '"+sqlFromDate+"' and '"+sqlTillDate+"' " ;
            System.out.println(query1);
              Class.forName(driver);
             DriverManager.getConnection(url);
             preparedStatement=connection.prepareStatement(query1);
             preparedStatement.setString(1,"MTName");
              preparedStatement.setDate(2,sqlFromDate);
              preparedStatement.setDate(3,sqlTillDate);
              resultSet=preparedStatement.executeQuery();           
               while(resultSet.next())
                        System.out.println(resultSet.getString(1));
                        System.out.println(resultSet.getDate(2));
                        System.out.println(resultSet.getInt(3));
            catch (Exception e)
             e.printStackTrace();
    I Passed value from my main method is like thisl
    databaseConnection("prasu","1/12/2005","31/12/2005");Please provide solutions or provide some sample codes!
    Help!
    Thanks in advance for replies

    Thanks for ur reply Mr.Rajasekhar
    I tried as u said,
    i tried without converting to sql date ,but still i din't get any results
    java.text.SimpleDateFormat dateFormat=new java.text.SimpleDateFormat("dd/MM/yyyy");
             java.util.Date fromDate=dateFormat.parse(startDate);
            java.util.Date tillDate=dateFormat.parse(endDate);          
              String query1="select MTName,Date,MTLineCount from linecountdetails where mtname='"+MTName+"'  and Date >='"+fromDate+"' and Date <='"+tillDate+"' " ;
            System.out.println(query1);
    //From main method
    databaseConnection("prasu","1/12/2005","31/12/2005");I got the output as
    ---------- java ----------
    select MTName,Date,MTLineCount from linecountdetails where mtname='prasu'  and Date >='Thu Dec 01 00:00:00 GMT+05:30 2005' and Date <='Sat Dec 31 00:00:00 GMT+05:30 2005'
    java.lang.NullPointerException
    null
    null
    java.lang.NullPointerException
    Output completed (4 sec consumed) - Normal TerminationThanks
    Prasanna.B

  • File Download in JSP, Please help

    I am wondering if somebody can help me with a problem :
    I am trying to register a fact that somebody has downloaded a file
    from my company's website.
    When a user clicks on the link I provided, a message box came up to prompt user with the location to save the file. How can I register the fact that user press "Cancel" instead of OK. In other words I need to be able to tell whether the guy really downloaded it or not.
    Thanks

    So, how to determine if user had pressed 'Cancel' or just the connection is broken?
    The pure JSP cannot do it.
    I think you should have some binary code like applet or active-x to check it.

  • Implementing session timeout in JSP - - Urgent help !

    Hi
    I have a requirement where I need to write a session timeout functionality in a JSP such that the page is redirected to a different page if there is no activity for 5 min.
    I tried the following :
    1.On the onload of my JSP, i created a new session from the current request using the following code snippet :
              HttpSession pSession = request.getSession(true);
              pSession.setAttribute("loggedin","true");
              pSession.setMaxInactiveInterval(10);
    2. Then on any action performed on the JSP, i called the collowing JS function before invoking the server side code.
    /** function to check the user session **/
    function fnChkSession()
         alert('Inside check session');
         <%
              try
                   System.out.println("The value of the session var loggedin : "+pSession.getAttribute("loggedin").toString());
                   System.out.println(" getMaxInactiveInterval() value is : "+pSession.getMaxInactiveInterval());
              catch (Exception e)
                   System.out.println("** Inside the fnChkSession exception catch block **");
              if (pSession.getValue("loggedin") == null)
         %>
              alert('Session has expired');
              document.forms[0].submit();
         <% } %>
    But when I execute this code ,even after 10 secs my session seems to be alive.I can retrieve the session attribute after 10s.
    I also tried setting the session-timeout value in the web.xml. It didnt work.
    Can anyone pls help me on how to proceed further on this.
    Thanks
    Arun B

    You are confusing java with javascript.
    These two things are not the same.
    The lifecycle goes something like this
    1 - Request is made to server
    2 - Java/JSP runs java code, produces HTML page
    3 - java stops running
    4 - html is sent to browser, and javascript starts running.
    You cannot call java code from browser events (such as onload, onclick, onchange...) The only way to run java code again is to submit a request (normally by submitting a form, or clicking a link. )
    If you want a javascript solution, in IE, use the window.setTimeout() method to execute some javascript code after a certain period of time.
    A more generic approach would be to use the refresh header. Set the timeout for the refresh header to be 300 seconds. If the user stays on the same page for more than 5 minutes, it will redirect to the new page.
    Hope this helps,
    evnafets

  • Class cast exception in jsp plz help

    i have written a jsp where i displayed a text box with value given by user inside it
    when the user enters some other value in text box and clicks on update button then i forwarded reqeust to servlet which will some data base work
    servlet will forward again to the same jsp with the new value in text box.
    but i am getting CLASS CAST EXCEPTION when servlet is forwarding reqeust to same JSP
    help me what to do ........
    thanking you in advance ..cheers

    display cart.jsp file:
    <%@ page import="java.util.*,org.*" %>
    <html>
    <body>
    <%
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    CartListBean clb = (CartListBean)cartupdate.elementAt(i);
    %>
    <form name="itemslist<%=i%>" action="updateCart" method="post">
    <input type="hidden" name="itemcode" value="<%=clb.getItemCode()%>">
         <input type="hidden" name="itemname" value="<%= clb.getItemName()%>">
    <input type="hidden" name="price" value="<%= clb.getPrice()%>">
    <%= clb.getItemName() %>
    <input type="text" name="qty" value="<%=clb.getQuantity()%>">
    <input type="submit" name="<%=clb.getItemCode()%>" value="update">
    </form>
    <br>
    <%
    %>
    <form name="tobuy" action="buysrv" method="post">
    <input type="submit" name="buy" value="BUY">
    </form>
    </body>
    </html>
    updatecart servlet code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import org.*;
    import java.sql.*;
    import java.util.*;
    public class UpdateCart extends HttpServlet
    public void service(HttpServletRequest request,HttpServletResponse response) throws IOException,ServletException
    HttpSession session=request.getSession(false);
    Vector cartupdate = (Vector)session.getAttribute("cartlist");
    for (int i = 0; i < cartupdate.size(); i++) {
    org.CartListBean cart = (org.CartListBean)cartupdate.elementAt(i);
    if((cart.getItemCode()).equals(request.getParameter("itemcode")))
    org.CartListBean clb=new org.CartListBean();
    clb.setItemCode(request.getParameter("itemcode"));
         clb.setQuantity(request.getParameter("qty"));
         clb.setItemName(request.getParameter("itemname"));
    clb.setPrice(request.getParameter("price"));
    cartupdate.setElementAt(clb,i);
    session.setAttribute("cartlist",cart);
    ServletContext application=getServletContext();
    System.out.println("got finished");
              RequestDispatcher rd=application.getRequestDispatcher("/displaycart.jsp");
                   rd.forward(request,response);
    Message was edited by:
    143java

  • How to pass variables between 2 jsp pages-help

    Hi,
    I have a question like this.
    As an example consider I have 3 .jsp pages.
    page1.jsp - In this html form it has some textboxes to enter employee details.
    page2.jsp - In this page it has a "PRINT" button which allows the user to click.
    page3.jsp - A new popup window which having the same content as page2.jsp, but without the PRINT button.
    But my problem is this. In this page3.jsp,it should be display the entered textbox values as page2.jsp. But these values are not displaying here. They display as NULL.
    I use as follows, but it still not working.
    <%= request.getParameter("effDate")%>.
    Could you please tell me how to hold these values when I came from page2 to page3.
    I'm using JSP 1.2 with javaBeans.
    Thanks.

    Well,
    If you are popping up a new window, and you insisting on pulling the data out of the request's parameter map. Then you will need to add the values to the query string of your url.
    window.open("http:localhost/page3.jsp?itemOne=itemOneValue&itemTwo=ItemTwoValue, '', '');
    Alternative Option:
    When posting from page 1 to page two, store your information into session scope
    request.getSession().setAttribute("valeuOne", "valueOneValue");
    Then instead of pulling from the paramter map, use request.getSession().getAttribute("valueOne") in your third page.
    Hope that helps.
    Thanx
    Cardwell

  • Use bean in jsp, please help me out

    Hi all,
    As a beginner in jsp I want to use a bean into my jsp page. But this bean is sourcing from a old applet (i've converted the code applet into beans code), and should return a chart (grpahics).
    Here is the heart of my problem : how can i replace, call , or set up the paint method from the applet. And call it into my jsp page in order to retrieve a chart ?
    Basically all applet shall have a paint method with a Graphics argument , in jsp i can't do
    Mypackage.mybean.paint(Graphics g);
    Hope someone will be able to help me
    Thanks in advance
    Shamann

    I don't think that you can use the Graphics object in a JSP. A JSP is executed on the server side and only the output from that will be sent to the client. If you want to use Graphics objects etc, I think that you'll have to send it to an applet (possibly embedded in the page), but since I've never done this, I can't help you, I'm afraid.
    HTH,
    Raj.

  • Newbie to JSP needs help

    I'm running tomcat and apache and basic servlets work fine, however when I try the usebean tag; I get an error message "CLASS not found". The class object is in the same directory as the servlet?
    Any suggestions?
    Kurt Radamaker
    Orlando FL

    I don't think it is. How do I tell? I'm pretty green with jsp and java, so I'm sorry I can't be of more help.
    Kurt Radamaker
    Orlando FL

  • Double sql statements in JSP..HELP...

    When I use this code in a single JSP file it doesn't update the database....I guess there is something wrong with this....There is no error but in JSP but It doesn't update....Need help guys....
    String SQLStatement = "select * from test, test1";
    String SQLStatement1= "update test
    set total_shares=total_shares - sTotal
    where stock_code=Scode AND name_broker=Sbroker";
    I get the Scode and Sbroker from the other table so I used the SELECT first...

    String SQLStatement1= "update test
    set total_shares=total_shares - sTotal
    where stock_code=Scode AND name_broker=Sbroker";What are Scode and Sbroker ? Are they String datatypes? If yes, you can't be putting them as is within quotes. Please give the complete code.

  • Paging in JSP ! HELP! HELP! HELP!

    somebody can order an example to me of paging of results in JSP... or tutorial address that has some scritpt and. since already I am thankful!
    [email protected]

    If you are interested in creating some type of paging functionality you will need a few things. First, i will assume you have some set of data that you want to page. Let's say you have an array of Objects that has 100 total elements.
    You will most likely define a pageSize value that defines how many elements to display on the current page. You will also want to define a pageNumber to represent the current page that you are on.
    So lets say that you have a pageSize = 10.
    You should define some Java method in a class that has access to the complete array, which takes the pageSize and pageNumber as parameters, and returns an array of the same type.
    For example, lets say you have a class called EmployeeSet
    public class EmployeeSet
    private Employee[] totalEmployeeSet;
    public void setEmployeeSet
    //some code that populates the totalEmployeeSet array
    public Employee[] getEmployeeSet()
    return totalEmployeeSet;
    public Employee[] getCurrentEmployeePage(int pageSize, int pageNumber)
    // some logic to check that parameters are within valid range
    Employee[] currentEmployeeSet = new Employee[pageSize];
    //now store the current range into your current set
    //loop through the totalEmployeeSet starting at the correct
    //point (pageNumber*pageSize), and store each element
    //into the currentEmployeeSet
    return currentEmployeeSet;
    I left out some important logic to determine whether the inputs to the method are valid or not, and whether the current page can display 'pageSize' elements or not. I am sure you can figure that out.
    I hope this helps some.
    -Dras

  • Paging in JSP(Scriptlets) help-me! help-me! help-me!

    Somebody can order an example of paging in JSP. does not obtain to make the paging.... Please, somebody can help.....� an urgency case me! In case that somebody has some example please, [email protected] orders pro email If possivel in Scriptlets
    Very Obliged!

    <%@ page import="java.sql.*" %>
    <%@ page errorPage="err.jsp" %>
    <%
    By VendeW and Shibayama
    %>
    <html>
    <body>
    <center>
    <h2>Pagina��o usando JSP e MySQL</h2>
    <table border="2">
    <tr bgcolor="tan">
    <th>id</th><th>Titulo</th><th>Image</th><th>Descri��o</th></tr>
    <%
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
    Connection conexao = DriverManager.getConnection("jdbc:odbc:book");
    Statement declaracao = conexao.createStatement();
    Statement declaracao2 = conexao.createStatement();
    int limitePorPagina = 5;
    ResultSet resultado = declaracao.executeQuery("Select * from tbl_livro limit " + request.getParameter("pr") + "," + String.valueOf(limitePorPagina));
    ResultSet rs2 = declaracao2.executeQuery("Select count(*) as c from tbl_livro");
    rs2.next();
    int totalregs = Integer.parseInt(rs2.getString("c"));
    %>
    <b>Total de Registros: </b><%=totalregs%>
    <%
    int totalpgs = Math.round(totalregs / limitePorPagina);
    out.write("<b>P�ginas:</b> " + totalpgs);
    if ((totalregs % limitePorPagina) > 0) totalpgs++;
    int pr = Integer.parseInt(request.getParameter("pr"));
    try {
    while (resultado.next()) {
    String id = resultado.getString("id_livro");
    String nm = resultado.getString("nm_livro");
    String img = resultado.getString("image");
    String desc = resultado.getString("desc_livro");
    %>
    <tr>
    <td><%=id%> </td>
    <td><%=nm%> </td>
    <td><%=img%> </td>
    <td><%=desc%> </td>
    </tr>
    <%
    }//while (resultado.next())
    %>
    </table>
    <%
    }//try
    catch (SQLException e) { out.println("SQL Error" + e); }
    if (pr > 0) {
    %>
    [Primeira P�gina] 
    <a href="?pr=<%=pr-limitePorPagina%>">[Anteriores]</a> 
    <%
    }//if (pr > 0)
    if (pr < (totalpgs * limitePorPagina) - limitePorPagina) {
    %>
    <a href="?pr=<%=pr+limitePorPagina%>">[Pr�ximos]</a> 
    <a href="?pr=<%=(totalpgs * limitePorPagina) - limitePorPagina%>">[Ultima P�gina]</a> 
    <%
    }//if (cont < totalpgs)
    %>
    </center>
    </body>
    </html>

  • Getting option value in jsp: Urgent help will be appreciated

    Hello All,
    I am working on JSP. I will grade myself as beginner in JSP.
    I am trying to solve since last 2 days, I just want to display the value of option tag, and not able to get it.
    <table>
    <tr>
    <td>
    <html:select name="ActionForm" property="overage">
    <%
    int i;
    int[] arr1=new int[200];
    for (i=0;i<=100;i=i+10)
    arr1=i;
    %>
    <html:option value="/<%=i%>/"><%= arr1%></html:option>
    <%}%>
    </html:select>
    </td>
    </tr>
    </table>
    Please, ignore the syntactical error.
    Now in above code I want to know what is being put up as value of option tag. By value I mean , I want see <html:option ]value="/<%=i%>/> . (Data marked in bold)
    Your help will be appreciated. I tried couple of things such as getParameter(), get Attribute(), getOverage(). Some of it gave me value as "//", it skips the i variable.
    I want to see what is being put up in value for every iteration of loop

    Yeah I know. But thnx for the response.
    I also got that error solved. you know what it was because of those bckslashes. i wrote it,
    <html:option value="<%=i%>"><%=arr%> instead of
    <html:option value="/<%=i%>/"><%=arr[i]%>
    and that worked perfectly. I wish I could have known this before. It would have saved me lot of time.

  • Tabs in JSP- Plz help-Urgent

    I want to have 3 tabs say Tab1, tab2, tab3 in my page and based on which tab is clicked , I have to display the contents of a table.
    Ex: if Tab1 is clicked, i have to display contents of Table1 and tab2,table2 and so ...
    Plz help with how to link the click on the tab to calling of the JSP file which retrives and displays the data???....
    Its urgent ;plz help

    dnamiot ,
    I'm also looking for similar funcitonality.
    the URL mentioned in your reply is not free ware. you know, it is tough to convince management to buy a software for the project even it is $1.
    So if you know any taglibrary which is free ware , which generates maximum of 4 tabs and dynamic in nature, please let me know.
    Thanks in advance
    tekbond

Maybe you are looking for