• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Accessing Servlet by HTML

 
Ranch Hand
Posts: 130
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi EveryBody

I have 1 Htm file start.htm with followin java script



function validateLogin() {
1.var Text1 = document.getElementById("Text1").value;
2.alert('Text1 = '+Text1);
3.var url = "http://localhost:8080/esb/AJAXUtil?Text1="+Text1;
4.xmlHttp.open("POST",url);
5.xmlHttp.onreadystatechange = callback;
6.xmlHttp.send(null);
}

function callback() {
7.alert('callback');
8.if(xmlHttp.readyState == 4) {
9.if (xmlHttp.status == 200) {
10.var response = xmlHttp.responseText;
11.alert ('response = '+response);
}
}
}

The above is the ajax implementation and work good if I rename the file to index.jsp put it to the root folder of the application.

But in my scenerio I have to put the file in somewhere else.
I get error in javascript in line 4.

Please suggest me the solution.

In other word I re explain my problem as.

I have an html page running on q-matic server. I wnat to connect to 1 of my servlet on tomcat to verify the telephone no.

Thank You
Syed Saifuddin
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

This post has been moved to a more appropriate forum.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

But in my scenerio I have to put the file in somewhere else.

We can't help you unless you tell where that "somehwere else" is. Is it in the same web application? If so, you need to verify that the URL you are using is correct.

If not, is it from a web app on the same server?

Is it on a differrent server? If so, you'll run into trouble with the Ajax security model (which can be solved with a server-side proxy relay).

Which scenario represents your issue?
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Syed,

there's probably something in your JSP (maybe a scriptlet?)
that declares and initializes the xmlHttp variable.
And of course scriptles won't work in a html file.

Maybe you can post some of your JSP-code.

Herman
 
reply
    Bookmark Topic Watch Topic
  • New Topic