wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
Author

Updating part of an html page on button click

Polina Esta
Greenhorn

Joined: Jul 16, 2011
Posts: 1
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

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.


S.D. MADHAN
Not many get the right opportunity !
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Updating part of an html page on button click
 
Similar Threads
Problem with JSPs in web application
how to save a transaction screen
Problem with Jeditorpane
servlet
Display all Users Detail on JSP page when we Loged in through ADMIN