473,659 Members | 3,239 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Serving a JavaScript file from a Servlet

I'd like to generate a JavaScript file from a servlet. Mozilla 1.5
seems to have no problem with this, but IE 6.0 is not cooperating.

I've created a very simple test servlet that writes one line:
alert("hello");

I have an HTML page that looks like this:
<html><head>
<script language="javas cript" src="/servlet/Test"></script>
</head></html>

If I don't use the page, but instead use the URL for the script
directly from my browser, in Mozilla the page comes up. (Normal
Mozilla behavior - it displays the page rather than loading it.) In
IE, I instead get an error message:

Internet Explorer cannot download Test from localhost
Internet Explorer was not able to open this Internet Site.
The requested site is either unavailable or cannot be found.
Please try again later.

Does anyone have any idea why IE can't display the page? I've tried
using a variety of MIME types (text/javascript, text/JScript,
application/x-javascript) and nothing seems to work. One interesting
note -- if I change the Mime type to text/html, the alert("hello")
will show up if I am using the URL directly.

Has anyone else done this? Please help, I'm out of ideas.
Jul 20 '05 #1
1 4608
I have had no problem, however I point to a JSP file instead of a servlet
and I use the following content type:
<%@ page contentType="te xt/javascript" %>
"Matthew Flower" <Ma********@yah oo.com> wrote in message
news:b7******** *************** ***@posting.goo gle.com...
I'd like to generate a JavaScript file from a servlet. Mozilla 1.5
seems to have no problem with this, but IE 6.0 is not cooperating.

I've created a very simple test servlet that writes one line:
alert("hello");

I have an HTML page that looks like this:
<html><head>
<script language="javas cript" src="/servlet/Test"></script>
</head></html>

If I don't use the page, but instead use the URL for the script
directly from my browser, in Mozilla the page comes up. (Normal
Mozilla behavior - it displays the page rather than loading it.) In
IE, I instead get an error message:

Internet Explorer cannot download Test from localhost
Internet Explorer was not able to open this Internet Site.
The requested site is either unavailable or cannot be found.
Please try again later.

Does anyone have any idea why IE can't display the page? I've tried
using a variety of MIME types (text/javascript, text/JScript,
application/x-javascript) and nothing seems to work. One interesting
note -- if I change the Mime type to text/html, the alert("hello")
will show up if I am using the URL directly.

Has anyone else done this? Please help, I'm out of ideas.

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4252
by: Patrick | last post by:
I am trying to download the html page at http://www.dreamteamfc.com/dtfc04/servlet/PostPlayerList?catidx=1 Using the code public class DownloadWebPage { public static void main (String args) throws IOException { URL url = new
3
6748
by: Andy Fish | last post by:
Hi, I have a webpage with some javascript that constructs some data structures, some of which contain nested structures or arrays of other structures. It's the same order of complexity as a web.xml file, say. I need to post the whole lot to the server and I'm not sure which is the best way to do it. It has to be browser-independent. The only ways I can think of are:
2
2464
by: Rose Girl | last post by:
Hi Need some help on javascript. I need to know how to call a servlet from a javascript function. web-inf (jboss) path for servlet is: com.purpleace.ripple.admin.contacts.servlet.AdminReport web xml <servet-mapping> is :
3
3674
by: Prash | last post by:
IIS serving javascript files, gives me error 4/21/2006 6:48 AM Guys/Gals, I am using IIS as a server to serve the javascript files. But it is giving me the error as "Object doesn't support this property or Method". I have modified the plugin-cfg.xml, to discard the entries of js files. Also, i checked to insure that the .js extension is added to the IIS mime type list by adding a mime type for .js as IIS6 will not serve up
10
2664
by: Tom Cole | last post by:
While I've done javascript work for as long as I can remember (since Netscape first released it), I've only ever used it for trivial things, change a color here, validate a text element there, blah blah blah. With Ajax (actually, the uncovering of the XmlHTTPRequest object) I absolutely see the benefit of moving more of the UI work to the client, rather than doing page refreshes. I know there are a bunch of libraries out there...
9
4124
by: ajos | last post by:
hi all, im getting some problems in my javascript validations..... my jsp code--> 8: <head> 9: <title>Budget Master Administration</title> 10: <meta name="GENERATOR" content="Microsoft FrontPage 3.0"> 11: <html:javascript src="bscript.js" method="everything(this)" staticJavascript="false"/> 12: <!-- <SCRIPT LANGUAGE="JavaScript" SRC="bscript.js"></SCRIPT> --> 13: <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
2
3449
by: ManidipSengupta | last post by:
Hi, a few (3) questions for the Java experts, and let me know if this is the right forum. It deals with 100% java code (reason for posting here) but manages a Web browser with Javascript. Thanks in advance for responding. I have made a stub of the codes for better understanding. Situation: I have a Java servlet (HelloWorldServlet) running on a Tomcat (5.5.26) server on a Linux machine (compiled in JDK1.4.2). It writes Javascript to construct...
6
6845
by: moongeegee | last post by:
I have compile my java program as myjava.class. And I can run as "java myjava" without any program. As now, I need to execute myjava.class in javascript. Please shed a light how to execut "java myjava" in my javascript. Thanks a million.
7
8872
by: vinodsk101 | last post by:
Hi all, I have one doubt, can we pass a variable from javascript to servlet??? In Brief, i am getting some values in javascript through jsp and the same values i want in servlet. Ya i know i can get this values in servlet by using request.getParameter(""); But thise values are dynamically generated so i dont know how many values will be. so i am planning to put some array list so that i can forward this values to servlet. but i can't...
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.