?
Solved

Help on HTML

Posted on 2016-07-22
1
Medium Priority
?
92 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 total points
ID: 41725130
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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

719 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