Solved

Help on HTML

Posted on 2016-07-22
1
62 Views
Last Modified: 2016-07-23
Hi Team,

Iam developing an application where in I need to integrate HTML with Servlets and servlets to interact with Database using JDBC and send the results back to HTML page withour refreshing it.

It would be of great help if anyone can help with an example . Iam new to Java related technologies.
0
Comment
Question by:sam_2012
1 Comment
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
Comment Utility
I am not a java developer and perhaps you need to break your question down to two parts.  One for the back end and one for the front.

On the front end, you want to use an ajax request to your back end page.

You can do this in pure javascript, I like to  use jquery
http://api.jquery.com/jquery.ajax/
$.ajax({
  method: "GET",   
  url: "processpage",
  data: { first: "hello", last: "world" }
})
  .done(function( data) {
    alert( data);
  });

Open in new window


On your processpage, accept the get just as if the page was processpage?first=hello&last=world

On your main page, make a page using code similar to what I have above
<!DOCTYPE html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.0.3.js"></script>
  <script>
    $(function(){
    $.ajax({
  method: "GET",   
  url: "processpage",
  data: { first: "hello", last: "world" }
})
  .done(function( data) {
    //alert( data);
      $('#results').html(data);
  })
    
});
  </script>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>test</title>
</head>
<body>
  <div id="results"></div>
</body>
</html>

Open in new window

When you run the code on the main page above and your other page called processpage can extract the url processpage?first=hello&last=world and output "hello world" you will see that text in the div id results.

How you connect to your database in your java page is another process.

If this makes sense you are good to go.  If not, take just one piece at a time before going on to the next.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
Any business that wants to seriously grow needs to keep the needs and desires of an international audience of their websites in mind. Making a website friendly to international users isn’t prohibitively expensive and can provide an incredible return…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now