tags:

views:

14

answers:

0

I am just learning how to use JSP and am stack on a small issue. I am creating a basic form where the user inputs some text and then when they submit the form it gets sent to a JSP page.

The JSP then outputs what the user inputted using the request.getParameter() call. Now this works fine but i would like the data to be sent to a JSP page that is then loaded into a div section below the form. For example:

<form action="handleStock.jsp" method="post">
    <fieldset>
        <legend>Please Enter Stock Symbol</legend>
            <label for="stockSym">Stock Ticker</label>
            <input type="text" name="stockSym" /> <br/>
            <input type="submit" value="Lookup">
    </fieldset>
</form>

<div id="symbolStats">
</div>

The data is sent to handleStock.jsp :

<%
    String symbol = request.getParameter("stockSym");
    out.println(symbol);
%>

From this i would not like the handleStock.jsp page to be loaded into the div section below the form rather than on a seperate page.

Below is some AJAX code i wrote for another website which will load a page into a div section, how could i modify the code to actually load the jsp code after it has processed the data from the form.

ajaxRequest.onreadystatechange=function()
{
    if (ajaxRequest.readyState==4 && ajaxRequest.status==200)
        {
            document.getElementById("page_Disp").innerHTML=ajaxRequest.responseText;
        }
    }
    ajaxRequest.open("GET", link + ".jsp", true);
    ajaxRequest.send();
}