Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating part of an html page on button click

 
Polina Esta
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm a complete beginner in JSP. Please advice me on the following issue:

What I need to do is to bring a list of values from database on button click and display them as a list in my html page.

First I tried using servlet and writing my data like this:

protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<h1>hello</h1>");
out.close();
}

Instead of "hello" I print my list from the database. But this way instead of getting my previous html and the data I print in the servlet I get only what I print in the servlet.

As far as I understand ajax is used to update a part of an html page. But in this case I have to write an asp file to manage the desired output and access database via asp code. But I want to access database using java.

Thanks a lot, and please excuse my complete ignorance


 
Madhan Sundararajan Devaki
Ranch Hand
Posts: 312
Java MS IE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a beginner, fetch the data from the database in the Servlet using JDBC and construct the complete HTML document (including the database values) as response from the Servlet.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic