Your server is not support J2EE? Why returned the java source?
You'd better post your web.xml.
By the way, your servlet class should have a pakage name!
Main Topics
Browse All TopicsWorking with ajax I am excited because my javascript can call my server code. however the response returned is not correct as the responce is the first three chrtrs of the jave file and probably for good reason. the reason may be due to the url in the java script, which is
var url = "http://localhost:8080/kdb
SomehowI believe I would need to include something like:
?key=" + escape(key.value); but not sure how.
I am developing my first ajax aplication the that makes a request to the server. The Ajax project that I am trying to work on should evaluate a keystroke and convert it to a decimal value.
The app;ication should work as follows the user types a letter the letter in the field. The letter is passed to a javascript at which point a call to the server is made and a response is given, which is the decimal value of the key stroke.
Found below in the doc is appicture of my directory and screen shot
Please let me know if you need to see the web xml.
Found below is the code to my project and screenshot of my results.
Please Help!!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Hello hielo:
I did add the code as provded but resuls are the same. The return is the same: /* * sTakes
Hello xxli79:
Found below the web xml, which I believe has been altered in the past but seems to have been restored to the code found below. (The alteration was done manually by me but I do not currently see the alteraion)
(Code is Below)
You stated: Your server is not support J2EE? Why returned the java source?
I am not sure if you are asking a question or telling me a piece of information in either case let me tell you why I used the link found below: Because I was getting a 404 error code and the link below gave me a 200, which I believe is good and need to know how to complete:
var url = "http://localhost:8080/kdb
You stated: By the way, your servlet class should have a pakage name!
Not exactly sure how to do this but maybe this will be come a new question. Can I still make the application work without a package name or is it easier to open a new question that asks how to add a new package name to a already created application?
The way you worded your question made it seem as if though you didn't know how to pass the parameters via the querystring. However, after reading the response from xxli79, I see now what you are doing wrong.
Basically, if you were to have a file named hello.txt and it had only two words in it:
Greetings Stranger
Then if you used:
var url = "http://localhost:8080/kdb
the server will see that you are requesting a .txt file. Web servers typically do NOT execute txt files, so assuming that is the case with your server as well, then the server will just send the "raw" content of your .txt file. So basically your client-script will receive "Greetings Stranger". Notice, that if you changed the content of your txt file to:
<?php
$x="howdy";
echo ( $x );
?>
your client-side script will still NOT get just "howdy". It will literally get the complete "raw" content of the file - namely:
<?php
$x="howdy";
echo ( $x );
?>
Why? Again, because the server does NOT execute a .txt file. It just opens it, reads the content and sends it as is. The point I am trying to make is that NOT ALL files on the server are interpreted. In your case, it seems that your .java files are not executed. Perhaps a server misconfiguration?
I am not a JSP developer so I don't know what you would need to do to get your pages working, but from the problems I have seen here, you would typically "point" the url to a .jsp page, not to a .java file. Since you are pointing the url to a .java source code file, and the server doesn't interpret .java files, it sends the "raw" content, similarly like it would do with a .txt file. Makes sense?
hielo:
You wrote: The point I am trying to make is that NOT ALL files on the server are interpreted. In your case, it seems that your .java files are not executed. Perhaps a server misconfiguration?
Thank you for your kind reply and insight. I do not believe this to be a server misconfiguration issue. i believe it has to do with identifying the correct url variable and possibly the correct web.xml code. Let us see if xxli79, kadaba: or any other experts have differing opinions or suggestions.
I'v checked you web.xml.
First, make your servlet run:
1. define a package name for your servlet class.
at the first line of your .java file, add a new line: package ajaxtest;
and move your .java file to a new directory named ajaxtest.
2. modify the web.xml:
<servlet-class>ajaxtest.Ajax
3. redeploy your webapp and test it directly:
http://xxxx[:port]/[webapp
And you can referrence: http://java.sun.com/j2ee/t
Second, make ajax run:
1. replace your url as:
http://xxxx[:port]/[webapp
2. test again.
Hello xxli79,
1. define a package name for your servlet class. (See document attached to this post
Created package - Deleted old package created new
Path within web.xml - JavaSource/servletdg/AjaxR
2. modify the web.xml: My code is as follows but still have question with observation stated below.
<servlet-class>JavaSource.se
The following url provides a 404 (connecting to java)
Item # 3 tried test both urls both result in 404
var url = "http://localhost:8080/kdb
var url = "http://localhost:8080/kdb
Observation
The web.xml seems to have an error as there is a yellow spot on the globe not sure what this means or how to fix. Maybe there is a way to rebuild??
Please not prior to test, I did stop and restart tomcat.
I think I am getting close
Business Accounts
Answer for Membership
by: hieloPosted on 2009-10-14 at 17:20:06ID: 25576373
>>SomehowI believe I would need to include something like:
?key=" + escape(key.value); but not sure how.
Correct. Instead of:
Select allOpen in new window