Database query ResultSet from servlet to JSP page

          Hi there,
          I have an Access 2000 database. I am running Apache and Tomcat on Windows Me.
          I would like to know if it is possible for me to use a Servlet to search the
          database (I know this bit is possible!), but then I would like the servlet to
          forward to a jsp page which will then display the ResultSet that the servlet has
          retrieved, i.e. when forwarding from a servlet to a jsp, is it possible for the
          jsp page to have access to the servlet's data? I know that it gets access to
          the response and request objects, but what about a ResultSet?
          Sorry it this sounds a little silly - i am a bit of a newbie.
          Thanks in advance for your help,
          SJ
          

HttpServletRequest.setAttribute let's you share data for a particular
          request. When you call forward you can store the resultset in the request.
          Make sure your JSP does close the result set though, because what you are
          trying to do doesn't sound good :)
          If you want to share data across the session, take a look at the HttpSession
          object.
          read through the servlet specification, it is fairly easy to read and will
          give you all the info you need
          Filip
          ~
          Namaste - I bow to the divine in you
          ~
          Filip Hanik
          Software Architect
          [email protected]
          www.filip.net
          "SJ" <[email protected]> wrote in message
          news:[email protected]...
          >
          > Hi there,
          >
          > I have an Access 2000 database. I am running Apache and Tomcat on Windows
          Me.
          > I would like to know if it is possible for me to use a Servlet to search
          the
          > database (I know this bit is possible!), but then I would like the servlet
          to
          > forward to a jsp page which will then display the ResultSet that the
          servlet has
          > retrieved, i.e. when forwarding from a servlet to a jsp, is it possible
          for the
          > jsp page to have access to the servlet's data? I know that it gets access
          to
          > the response and request objects, but what about a ResultSet?
          >
          > Sorry it this sounds a little silly - i am a bit of a newbie.
          >
          > Thanks in advance for your help,
          >
          > SJ
          

Similar Messages

  • Returning ResultSet from servlet to jsp - java.lang.NullPointerException

    Hey all, i've been stuck on this for too long now...just trying to return a ResultSet from a servlet to jsp page.
    Had a bunch of problems earlier...which i think were fixed but...now i get a "java.lang.NullPointerException" in my jsp page when i try to get elements from the ResultSet object.
    Here is the latest version of my code:
    Servlet:
    String QueryStr="select ProdName from products";
    Statement stmt=conn.createStatement();
    rs=stmt.executeQuery(QueryStr); //get resultset
    sbean.setInventory(rs); //set ResultSet in bean
    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to bean
    Bean:
    package beans;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    public class SearchBean extends HttpServlet{
         private int searchFlag=0;
         private ResultSet inventory;
         public SearchBean(){
         public int getSearchFlag(){
         return searchFlag;
         public ResultSet getInventory(){
              return inventory;
         public void setInventory(ResultSet rs){
              this.inventory=rs;
         public void setSearchFlag(){
              this.searchFlag=1;
    jsp:
    <%@ page language="java" import="java.lang.*,java.sql.*,javax.sql.*,PopLists.PopInvLists,beans.SearchBean"%>
    <jsp:useBean scope="session" id="s_resbean" class="beans.SearchBean" />
    <% ResultSet categories=PopInvLists.getCat();
    ResultSet manuf=PopInvLists.getManuf();
    ResultSet supplier=PopInvLists.getSupplier();
    ResultSet cars=PopInvLists.getCars();
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");
    %>
    <%     while(search.next()){
         String pname=search.getString("ProdName");
    %>
    It craps out when i try to loop through the "search" ResultSet.
    I can loop through the rest of the ResultSets no problem....just this one doesn't work because it's set in a servlet, not a simple java class.
    Just to clarify, i am populating some dropdown lists on entry to the screen, which the user will use to perform a search. Once the search btn is clicked, the servlet is called, gets the request info for the search, performs search, and returns the resultset to the original screen. I want to eventually display the result under the search criteria.
    Someone....Please Please please tell me how to get this working...it should be very simple, but i just can't get it to work.
    Thanks in advance,
    Aditya

    req.getSession(true).setAttribute("s_resbean",sbean); //create session/request variable, set to beanHere you add an attribute to the session.
    ResultSet search=(ResultSet)request.getAttribute("s_resbean");Here you try to get the attribute from the request. Naturally it isn't there because you added it to the session, not the request. Despite your comment in the first line of code, a session is not a request. And vice versa.

  • Parameter passing from servlet to jsp page

    Hi
    I m facing problem of parameter passing from servlet to jsp ..
    plz help me...
    I m using as ...
    in servlet code I m using ...
    request.setAttribute("string",parameter);
    and in jsp..
    request.getParameter("string");
    regard's
    JAI KUMAR

    Hi Jaykumar
    You should use
    <%= request.getAttribute("sting") %> or
    ${string}
    in your jsp. I think you are trying to retrive the parameter instead of attribute.
    Thanks

  • 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

  • Connecting to Servlet from a Login JSP page

    Hi Everyone can anyone tell how to invoke a Servlet say DBHandler servlet from a Login JSP page
    I am using JRun3.0
    If i do this i am getting an error Error 405 Resource not allowed
    The directory structure is as follows :::-----
    emtech\jsp\Login.jsp
    emtech\web-inf\classes\DBHandler.java
    in my Login.jsp page i am giving
    <form method="post" action ="DBHandler">
    </form>
    Help will be highly appreciated
    Thanking in advance
    Mumtaz
    India

    Hi
    Even after modifying i am getting the same problem
    if i use jsp:forward tag then it works fine ie transfers control fully to the servlet but if i set the form action
    like /servlet/LoginServlet or LoginServlet i get this in my url ---http://localhost:8100/emtech2/jsp/emtech2/servlet/LoginServlet
    i just am thinking of using JRun
    Plz help
    Thanking You

  • Pass data from servlet to jsp using sendRedirect

    Hi,
    I am passing data from servlet to jsp using forward method of request dispatcher but as it doesn't change the url it is creating problems. When ever user refreshes the screen(browser refresh) it's re-loading both servlet and jsp, which i don't want to happen. I want only the jsp to be reloaded.
    Can I pass data from servlet to jsp using sendRedirect in this case. I also want to pass some values from servlet to jsp but without using query string. I want to set some attributes and send to jsp just like we do for forward method of request dispatcher.
    Is there any way i can send data using attributes(without using query string) using sendRedirect? Please let me know

    sendRedirect is meant as a true redirect. meaning
    you can use it to redirect to urls not in your
    context....with forward you couldn't pass information
    to jsps/servlets outside your own context.Actually, you can:
    getServletContext().getContext("/other").getRequestDispatcher("/path/to/servlet").forward(request, response)I think the issue here is that the OP would like to have RequestDispatcher.forward() also update the address in the client's browser. That's not possible, AFAIK. By the time the request is forwarded, the browser has already determined the URL of the servlet, and the only I know of way to have the browser change the URL to the forwarded Servlet/JSP is to send a Location: header (i.e. sendRedirect()). Remember that server-side dispatching is transparent to the client. Maybe there's some tricky stuff you can do with JavaScript to change the address in the address bar without reloading the page?
    Brian

  • Message bundles accessed from JSF and JSP pages

    Hello, everybody!
    I'm developing a localized JSF application. It is working pretty well until now.
    These are my message files:
    mensagens.properties
    mensagens_en_US.propertiesThis is how they're configured in faces-config.xml:
    <application>
        <resource-bundle>
            <base-name>br.urca.www.biblioteca.web.mensagens</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>And this is how I access the messages in a page:
    <h:outputText value="#{msg.titulo}" />Nothing new until now. But now there was a need for me to have a raw jsp page in
    my web application. This page is displaying ok but I also need to access the
    message bundles as I'm able to access in the normal jsp with the JSF components.
    As you should know I can't use something like the above code with an +<h:outputText>+
    to access the messages because this is a JSF component and I'll not be able to use
    JSF components with this raw jsp page.
    So, my question is: how do I access my localized messages from a raw jsp page? I
    suppose there should be a way to do this, but unfortunately I started programming
    to the web world in Java with JSF, not JSP, so I don't know how to do this with
    JSP.
    Thank you very much.
    Marcos

    BalusC wrote:
    Just include [jstl-1.2.jar|https://maven-repository.dev.java.net/repository/jstl/jars/] in your classpath and define the fmt taglib in your JSP. Nothing more is needed.
    Hello, BalusC. Thank you for your help. We're almost there. After I have included the jstl-1.2.jar you provided me I can use the fmt tag and access message bundles from my raw jsp page (even though I had to provide other message bundles instead of the ones that I use in the other jsf pages, but it's better than nothing).
    Now there just on problem to be fixed. The jsp page is not aware when I change the locale of my application. I change this locale in a jsf page.
    I have this component:
    <h:selectOneMenu value="#{pesquisaAcervo.idiomaAplicacao}"
        valueChangeListener="# {pesquisaAcervo.idiomaAplicacaoMudado}" onchange="submit();">
        <f:selectItems value="#{pesquisaAcervo.idiomasAplicacao}" />
    </h:selectOneMenu>that calls this event in my backing bean class:
    public void idiomaAplicacaoMudado(ValueChangeEvent e)
        fIdiomaAplicacao.liberarItens();
        Idioma idioma = Idioma.deString(e.getNewValue().toString());
        // This line is for JSF
        FacesContext.getCurrentInstance().getViewRoot().setLocale(idioma.localidade());
        // This line is for Tiles
        FacesContext.getCurrentInstance().getExternalContext().getSessionMap().
            put(org.apache.tiles.locale.impl.DefaultLocaleResolver.LOCALE_KEY, idioma.localidade());
    }So, do I have to include another line in the idiomaAplicacaoMudado event above in order for the jsp page load the correct resource bundle? Or what else do I have to do?
    Thank you.
    Marcos

  • How to send the values from servlet to jsp

    hi folks,
    I need to send a lot of values from servlet to jsp so that i can display the values in jsp. Any sollution for this. Its very urgent.
    Thanks in advance

    Hi lieo,
    Can u send me the sample code for that.
    Thank q

  • Passing database results from servlets to jsp

    Hi everyone,
    I have been trying to do what i thought would be a very simple thing...perform a search based on some criteria, and return the query result back to be displayed on a jsp page.
    I have a jsp page where some dropdown lists are populated on entry to the page. This works fine. I want to (eventually!) perform the search based on what is selected in these dropdowns. When i click the search button, i invoke a servlet called "SearchInventory.java" which gets the result. I then store this result in an ArrayList object. I then set a bean property (bean name->SearchBean, property->inventory) from within the servlet, and redirect back to the search page. This works if the query only gets back one column.
    Unfortunately, when i ask for more than one column in the query, i get a "java.lang.NullPointerException" error.
    Here is my code for all segments:
    JSP:
    <%@ page language="java" import="java.util.ArrayList,java.lang.*,java.sql.*,javax.sql.*,PopLists.PopInvLists,beans.SearchBean"%>
    <%
    SearchBean sbean=new SearchBean();
    ArrayList myAry=sbean.getInventory();
    int size=myAry.size();
    %>
    <%
              for(int i=0;i<size;i++){
                   String pname=(String)myAry.get(i);
         %>               
    <%}%>
    Servlet:
    String QueryStr="select ProdName,ManufName from products";// where ProdID="+ProdID;
    Statement stmt=conn.createStatement();
    rs=stmt.executeQuery(QueryStr);
    while(rs.next()){
         rowAry.add(rs.getString(1));
         rowAry.add(rs.getString(2));
         rowSetAry.add(rowAry.clone());
    sbean.setInventory(rowSetAry);
    req.getSession(true).setAttribute("s_resbean",sbean);
    res.sendRedirect("/DBTest/SearchInventory.jsp");
    In the servlet, i have also tried the following method of redirecting back to jsp page:
    String url="/SearchInventory.jsp";
    RequestDispatcher dispatcher=getServletContext().getRequestDispatcher(url);
    dispatcher.forward(req,res);
    ...this gives me a java.lang.ClassCastException
    here is my "bean" class:
    public class SearchBean extends HttpServlet{
         private int searchFlag=0;
         private static ArrayList inventory;
         public static ArrayList getInventory(){
              return inventory;
         public void setInventory(ArrayList rs){
              this.inventory=rs;
    When i perform a query that selects just one column, and doesn't use any sort of search fields for selecting, it does seem to work. for eg, : "select ProdName from products" as the query will return the product names successfully.
    Now, i realize what i'm doing is not correct....however, i don't know what the correct way of doing this is. Can someone please please show me how i should be going about doing all of this? It really shouldn't be difficult, but I just can't seem to get it to work.
    Thanks in advance,
    Aditya

    U have instantiated a search bean and populated its member variable i.e Array list , and added that bean to the session as an attribute. Then again why u need to instantiate the search bean in the jsp page.
    What has to be done.
    In the jsp page instead of instantiating the search bean ,get the search bean from the session attribute.
    statement to be removed : SearchBean bean=new SearchBean()
    statement to be added : SearchBean bean = session.getAttribute("bean");

  • Displaying Same ResultSet Twice In A JSP Page

    I have a table that lists team names in my database. I'm trying to create a page with 2 dropdown boxes where each lists all the teams in the league (in other words, the data read in from the table). I got the first dropdown box to populate w/ this info. My question is about the 2nd dropdown box:
    Since I already have the ResultSet from the 1st dropdown, I would think it would be a waste to make another DB-read to fill in the 2nd dropdown. However, when I tried to call ResultSet.first() it gave me the error that it was TYPE_FORWARD_ONLY. I checked the documentation for Connection and it looks like there are some overloaded methods for createStatement. However, the API documentation (see below) is pretty confusing. I'm not sure what "resultSetConcurrency" or "resultSetHoldability" I need if I just want to read the same data twice. Can someone point me in the right direction?
    Statement createStatement(int resultSetType, int resultSetConcurrency)
    Creates a Statement object that will generate ResultSet objects with the given type and concurrency.
    Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
    Creates a Statement object that will generate ResultSet objects with the given type, concurrency, and holdability.

    I am also having a very similar problem.
    I am having a table having 20 fileds.some of them r to be displayed in one table
    others in some other table.
    for this i am using a bean which returns a resultset which is then used in jsp page
    for display.But i have to call the javabean method twice which fires the query & returns the resultset.
    I cannot store so many fileds with so many rows of values in list of objects also i do not want to
    fire query twice.
    rs.movefirst() does not work, so what should i do.

  • How to send object arraylist from servlet to jsp and display using jstl

    Hi All....
    I have a simple application and problem with it.
    Once user logged in to system the user will redirect to LoginServlet.java controller.
    Then in LoginServlet I want to redirect user to another page called book_details.jsp.
    this is my login servlet.
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              // TODO Auto-generated method stub
              PrintWriter out = response.getWriter();
              ArrayList<BankAccountDTO> account_list = new ArrayList();
              ResultSet resultSet = null;
              LowFairAirDB airDB = null;
              try{
                   airDB = new LowFairAirDB();
                   String query = "SELECT account_id, type, description, balance, credit_line, begin_balance, begin_balance_time_stamp FROM bank_account";
                   airDB.sqlSelect(query);
                   resultSet = airDB.getResultSet();
                   while(resultSet.next()){
                        account_list.add(new BankAccountDTO(resultSet.getInt(1),
                                                                     resultSet.getInt(4),
                                                                     resultSet.getInt(5),
                                                                     resultSet.getInt(6),
                                                                     resultSet.getString(2),
                                                                     resultSet.getString(3),
                                                                     resultSet.getString(7)));
              }catch(Exception ex){
              }finally{
                   try{resultSet.close();}catch(Exception ex){}
                   airDB.sqlClose();
         }I set bank account values to BankAccountDTO.java objects and add them to the arrayList.
    Next I want to send this objects arrayList to books_details.jsp and wanna display each objects values using JSTL.
    I still finding a way to go through this.
    1. Can anyone say how can I do it?
    2. Is there any other method to do the same thing without using JSTL?
    thanks in advance,
    Dil.

    Naishe wrote:
    In your servlet,
    request.setAttribute("account_list", account_list);
    requestDispatcher.findForward("/your/display/jsp");
    Good. I would only follow the Java naming conventions. E.g. accountList or accounts instead of the ugly PHP/C conventions.
    In the JSP,
    lst = (List< BankAccountDTO >)request.setAttribute("account_list");
    for(BankAccountDTO b: lst){
    populate your HTML tags or whatever
    Wrong. 1) You need getAttribute() and 2) you should not use scriptlets. Use JSTL c:forEach, e.g.<table>
        <c:forEach items="${accounts}" var="account">
            <tr>
                <td>${account.id}</td>
                <td>${account.type}</td>
                <td>${account.description}</td>
            </tr>
        </c:forEach>
    </table>To the topicstarter: for future JSP/JSTL related questions please use JSP/JSTL forum.
    Here it is: [http://forums.sun.com/forum.jspa?forumID=45].

  • Access database query resultset in java scriptlet

    Question:
    1) I am Creating a web page and plotting points on the page:
    2) Database query results in decimal values dec_latitude and dec_longiitude.
    3) Perform calculations on lati. & long. in a java scriptlet to create a plot position (xpos, ypos).
    4) Send the xpos and ypos back to the java server page
    5) Use <IMG and absolute positioning to plot the point at position xpos, and ypos.
    6) Repeat until all rows in the query result set have been plotted.
    I don't know how to pass the dec_latitude and dec_longitude to the java scriptlet.
    After the java scriptlet calculation translates the latitude and longitude
    into xpos and ypos, I need to pass the xpos and ypos back to the java server page so that a data point is plotted on a map at position xpos, ypos.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    The code below results in a runtime error.
    Am I supposed to create a java object and access that in the java scriptlet? Can the java scriptlet access the latvar and longvar created during the "<c:set var="latvar"... ?
    If not, what mechanisum do I use to access the resulting colums: dec_latitude and dec_longitude? I need the java scriptlet to convert the
    dec_latitude and dec_longitude into a display position based on the number of pixels from the TOP and LEFT (xpos, ypos). Then plot of the data point using the IMG and (xpos, ypos). This will overlay a map whose z-index is lower than the plotted data point.
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar"); <--- runtime error !!!!
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    </c:forEach>

    Thanks
    I still get a runtime error: I translated the code you gave to code below .... which I think is equivalent. See Below: I'm still learning about this stuff so I may not have not translated this properly. Do
    you see what I am doing wrong?
    Best Regards,
    - John
    %@ page language="java" contentType="text/html;
    charset=ISO-8859-1"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page import="java.lang.Math"%>
    <sql:setDataSource dataSource="jdbc/SampleDB" />
    <c:set var="genus_name" value="${param.genus_name}" />
    <c:set var="species_name" value="${param.species_name}" />
    <c:set var="species_common_name" value="${param.species_common_name}" />
    <c:set var="dd_sighted" value="${param.dd_sighted}" />
    <c:set var="mm_sighted" value="${param.mm_sighted}" />
    <c:set var="yyyy_sighted" value="${param.yyyy_sighted}" />
    <c:set var="species_state" value="${param.species_state}" />
    <c:set var="species_county" value="${param.species_county}" />
    <c:set var="species_country" value="${param.species_country}" />
    <c:set var="dec_latitude" value="${param.dec_latitude}" />
    <c:set var="dec_longitude" value="${param.dec_longitude}" />
    <c:set var="notes" value="${param.notes}" />
    <c:set var="person_first_name" value="${param.person_first_name}" />
    <c:set var="person_last_name" value="${param.person_last_name}" />
    <c:set var="person_street" value="${param.person_street}" />
    <c:set var="person_city" value="${param.person_city}" />
    <c:set var="person_state" value="${param.person_state}" />
    <c:set var="person_zip" value="${param.person_zip}" />
    <c:set var="person_country" value="${param.person_country}" />
    <c:set var="person_email" value="${param.person_email}" />
    <h2>Species Sightings:</h2>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Breckenridge Citizen Bio-Survey Selective Output Page</title>
    </head>
    <body>
    Izaak Walton League of America
    <h1>Breckenridge Citizen Bio-Survey Selective Output</h1>
    <HR>
    <c:if test="${param.action == 'Submit'}">
    <%int xpos = 0;
         int ypos = 0;
         float latitude = 0.0F;
         float longitude = 0.0F;
         float latitudeMpls = 45.06F;
         float longitudeMpls = -93.14F;                    int xposMpls = 1205 - (int) Math.round(latitudeMpls);
         int yposMpls = 735 + (int) Math.round(longitudeMpls);
    %>
    <IMG SRC="minnesota_1990.jpg" ALT="minesota map" style="z-index:1;"> <----- THIS WORKS FINE
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2"> <----- THIS WORKS FINE FOR HARDCODED MPLS XPOS AND YPOS
    <sql:query var="qryBio">
    SELECT
    PERSON_FIRST_NAME,
    PERSON_LAST_NAME,
    GENUS_NAME,
    SPECIES_NAME,
    SPECIES_COMMON_NAME,
    SPECIES_COUNTY,
    SPECIES_STATE,
    SPECIES_COUNTRY,
    DD_SIGHTED,
    MM_SIGHTED,
    YYYY_SIGHTED,
    DEC_LATITUDE,
    DEC_LONGITUDE,
    NOTES,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    genus_name like rtrim(upper('${genus_name}')) AND
    species_name like rtrim(upper('${species_name}')) AND
    species_common_name like rtrim(upper
    ('${species_common_name}')) AND
    species_state like rtrim(upper('${species_state}')) AND
    species_county like rtrim(upper('${species_county}')) AND
    species_country like rtrim(upper('${species_country}')) AND
    person_first_name like rtrim(upper('${person_first_name}')) AND
    person_last_name like rtrim(upper('${person_last_name}')) AND
    person_email like rtrim(upper('${person_email}'))
    </sql:query>
    <c:forEach var="row" items="${qryBio.rows}">
    <--- THE LINE ABOVE WORKS FINE --->
    <c:set var="latvar" value="${row.dec_latitude}" scope="page" />
    <c:set var="longvar" value="${row.dec_longitude} " scope="page" />
    <%
    latitude =
    Float.parseFloat((String)pageContext.getAttribute("latvar"));
    <--- RUNTIME ERROR OCCURS HERE --- SEE LINE ABOVE --->
    longitude =
    Float.parseFloat((String)pageContext.getAttribute("longvar"));
    xpos = (int) Math.round(latitude);
    ypos = (int) Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    request.setAttribute("xpos",new Integer(xpos));
    request.setAttribute("ypos",new Integer(ypos));
    %>
    IIMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    <--- THIS (ABOVE) WORKS FINE WITH CORRECT VALUES FOR XPOS AND YPOS WHEN RUNTIME ERROR DOES NOT OCCUR --->
    </c:forEach>
    </c:if>

  • Getting ResultSet from Servlet

    How can I send a ResultSet to a JSP page from a servlet? I tried to use the req.setAttribute("name", rs) and forward to JSP with RequestDispatcher, but I get this error in the JSP page when doing "ResultSet rs = request.getAttribute("nome")":
    incompatible types
    found : java.lang.Object
    required: java.sql.ResultSet
    As you can see, the resultset became a java.lang.Object. Is there a way to convert the object back to a ResultSet?

    [snip]
    As you can see, the resultset became a
    java.lang.Object. Is there a way to convert the object
    back to a ResultSet? not addressing whether it's a good idea to throw a ResultSet at a JSP or not...
    getAttribute returns an Object, you "convert" it back to what you stuffed in there by casting, as
    ResultSet rs = (ResultSet)request.getAttribute("nome");Good luck
    Lee

  • Error message from servlet to jsp

    Hi again,
    I have servlet and check error on this servlet then i would like
    to send error message to jsp page.Every error message will send to
    same JSP page.So JSP must receive message from Servlet.Can i do this?
    Please give me details and some sourcecode.I will appreciate for your helps.

    you could do something like this..
    request.setAttribute("error", stringErrormessage);
    Then in the jsp just do
    <%= request.getAttribute("error") %>
    That will print an errormessage.
    Basically, by setting anything on the request and then redirecting to that page you cn display it...
    //Johan

  • Insert from button in jsp page

    hi, im new o jso and needto make an insert frim a jsp page with a button,
    what should i do?
    i made a javascript function but i really dont know if am i right and then i tried to call this function from the html tag
    beside this i execute de query from java and it was success!!, but i dont know what is wrong when i try from the jsp page with de button, please help!
    thx!
    here it's my code:
    <script type="text/javascript">
    import java.sql.*;
    function Agregar()
    return
    StringBuffer sb = new StringBuffer();
    try{
    Class.forName("org.postgresql.Driver");
    Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/Prueba","postgres","hola");
    Statement stmt = conn.createStatement();
    stmt.executeUpdate("INSERT INTO tbl_responsable (cedula,nombre,direccion) VALUES (14021752,'carlos','caracas')");
    }catch(Exception e){
    System.out.println("EXPLOTO");
    </script>
    ahora en el html que debo hacer??, o si tengo q hacer otra cosa???
    html del boton:
    <input type="submit" value="Agregar" action="Agregar()">
    what should i do, what its wrong??
    thx again!

    try this
    <input type="submit" onclick=" return Agregar();">
    or
    <input type="submit" onclick=" Agregar();">

Maybe you are looking for

  • Any word on when Oracle 10g Express Production

    version will be availble ?

  • Can oracle text be used to compare documents?

    lets say that i 've some documents stored in binary(LOB). can oracle text be used to compare documents and show their similarity on the basis of their content. how would i be able to compare documents using Oracle text. does it require mining algorit

  • Firefox doesn't work with flash ubuntu

    At first Firefox wouldn't work with flash videos. Now whenever I try to go to YouTube, it crashes. Whenever I try to view a video on break.com, it crashes. I have no idea how to get flash working in FF. It works in Opera, but not Firefox. I am curren

  • Using iphone 3GS to transfer itunes library from old computer to new comp.

    I am following all instructions provided at http://support.apple.com/kb/HT1329 but when I attempt to drag the itunes library into my iphone (which is listed under my computer) I am not able to. I have double checked and my itunes is set to "manually

  • Can't send mail on other networks

    We have been touring the country for two months now and find we often can't send mail (using Mail) on wireless networks in hotels and it happens when we are visiting friends as well. We can always receive mail, however. It's frustrating as we're keep