Results 1 to 2 of 2
  1. #1
    hussainzim is offline Member
    Join Date
    May 2008
    Rep Power

    Default how to send values from servlet.. using ajax to send some data according to the name selected from the combo box to the servlet..i hav managed to get the necessary values from the database to the servlet as a LIST but im clueless on how to send those values to jsp and print in the page...if i can hav a smaple code it would be very helpful..thank u in advance...


    Ajax Code..
    var selectedAuthor = author.options[author.selectedIndex].value
    var url = "/HRS2/AjaxServlet?author=" + escape(author.value);

    if (window.XMLHttpRequest) {
    req = new XMLHttpRequest( );
    else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
    req.onreadystatechange = callbackAuthor;


    function callbackAuthor() {

    if (req.readyState==4) {

    if (req.status == 200) {

    authorCheck( );



    function authorCheck( ) {
    //i think the printing comes here...

  2. #2
    lukky is offline Member
    Join Date
    Jul 2008
    Rep Power


    Hi friend,
    u can use the response.getwriter,write(String value);in the servlet.
    in the jsp page after response is coming,then u write the code at the ajax code.
    var s=xmlHttp.responseText;
    var tem=s.split("+");
    and to display the name in the page,u can write the code
    <div id="name"></div>

Similar Threads

  1. Replies: 4
    Last Post: 04-15-2008, 02:04 PM
  2. Replies: 1
    Last Post: 01-28-2008, 11:49 AM
  3. Replies: 0
    Last Post: 01-27-2008, 09:17 PM
  4. How to read attributes and values in a xml file using servlet
    By pragathi_forum in forum Advanced Java
    Replies: 1
    Last Post: 12-18-2007, 06:46 PM
  5. Getting HTML form values in Servlet
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-17-2007, 09:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts