wood burning stoves
The moose likes JSP and the fly likes Updating part of an html page on button click Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Updating part of an html page on button click" Watch "Updating part of an html page on button click" New topic

Updating part of an html page on button click

Polina Esta

Joined: Jul 16, 2011
Posts: 1
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 {
PrintWriter out = response.getWriter();

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

Joined: Mar 18, 2011
Posts: 312

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.

Not many get the right opportunity !
I agree. Here's the link: http://aspose.com/file-tools
subject: Updating part of an html page on button click
It's not a secret anymore!