Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6969587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:36:00+00:00 2026-05-27T16:36:00+00:00

I am using azax to dynamically change the jsp page and I want to

  • 0

I am using azax to dynamically change the jsp page and I want to send data from that jsp page to a servlet. The jsp code:

<input type="submit" oninput="loadXMLDoc(this.value)" value="ok" name="ok">
    <div id="myDiv">  
        Insert Id:<input id="p1" type="text" name="edit1" value=""style="visibility:hidden" size="30"/>
    </div>
function loadXMLDoc(str){
    var xmlhttp;
    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }else{// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function(){
    if (xmlhttp.readyState==4 && xmlhttp.status==200){
        document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
    }
}
xmlhttp.open("POST","edit?q="+str,true);
xmlhttp.send();
}

The servlet code:

 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter(); Connection conn=null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "studentdatabase";
    String driver = "com.mysql.jdbc.Driver"; 
    String userName = "root"; 
    String password = "1234";
    String student=request.getParameter("str");
    Statement stmt;out.println(student);
    try {
        Class.forName(driver).newInstance();
        conn = DriverManager.getConnection(url+dbName,userName,password);
        String query = "select name1,telephone,email,department from studentinfo where studentid='"+student+"";
        stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery(query);
        while(rs.next()){
            String s = rs.getObject(1).toString();
            out.println("<p> " +s+ "</p>");
        }
        conn.close;
        //System.out.println("Disconnected from database");
    } catch (Exception e) {
    e.printStackTrace();
}
}

The String student shows null even though there is value in the database for studentid=student.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T16:36:01+00:00Added an answer on May 27, 2026 at 4:36 pm

    Since you are using HTTP-POST you have to put your params into the send method.

    ...
    var params = "q="+str;
    xmlhttp.open("POST", url, true);
    
    xmlHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", params.length);
    xmlHttp.setRequestHeader("Connection", "close"); 
    xmlHttp.send(params);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Yii, I want to delete all the rows that are not from today.
Using a populated Table Type as the source for a TSQL-Merge. I want to
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using EF Code First I have an model object that has multiple properties that
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library
Using SSRS 2008 R2 I have a background process that dynamically generates RDL for
using this code I can send one texture to the shader: devcon->PSSetShaderResources(0, 1, &pTexture);
Using Java, how can I extract all the links from a given web page?
Using System.Diagnostics.EventLog .NET type one can programmatically create logs into the Event Viewer application.
using Telerik.WinControls.Data; using Telerik.WinControls.UI.Export; namespace Directory { public partial class radForm : Form {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.