RE: HttpListener based app loading Java Applet into html page

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



If the Html file contains tags to load the jar file, that's not what your
code is doing.
Your code:

int pos = context.Request.Url.AbsoluteUri.LastIndexOf("/");
string file = context.Request.Url.AbsoluteUri.Substring(++pos);

-- assumes that the request is directly for the jar file alone. What you
really need to be doing is serving the Html file that the request is asking
for, then you would get a subrequest from the browser reading the jar file
and you would need to serve that.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



"Reg" wrote:

I have a following code in HttpRequestListener's ProcessRequest method which
is a Windows
Console Application. I'm trying to read html page with browser (Opera) and
html file contains tags to include
Java Applet jar too,


for (int i = 0; i < numRequestsToBeHandled; i++)
{
HttpListenerResponse response = null;
try
{
// GetContext blocks while waiting for a request.
HttpListenerContext context = listener.GetContext();
// Create the response.
response = context.Response;
int pos = context.Request.Url.AbsoluteUri.LastIndexOf("/");
string file = context.Request.Url.AbsoluteUri.Substring(++pos);
byte[] buffer = new byte[32768];
// Reading html and Java Applet Jar file from file system
FileStream stream = new FileStream(file, FileMode.Open, FileAccess.Read);
int read = stream.Read(buffer, 0, buffer.Length);
stream.Close();
response.ContentLength64 = buffer.Length;
System.IO.Stream output = response.OutputStream;
output.Write(buffer, 0, buffer.Length);
output.Close();

Problem is that I get "Invalid Bytecode" error in Opera and IE shows
nothing.

Something missing, can anyone tell me what?

Cheers,



.



Relevant Pages

  • having trouble using signed java applet
    ... Hi i wrote an applet recently and posted a request here for help in allowing ... files that allow me access to functions normally prohibited to java applets. ... here's the steps i took in creating the self signed jar file. ... to test it i put the jar file and html file on there own on my website ...
    (comp.lang.java.programmer)
  • Re: Applet deployment problem
    ... But when I try to start it with a Browser with the generated ... HTML file I get error messages and I don't know what went wrong: ... in the manifest of your jar file. ...
    (comp.lang.java.programmer)
  • downloading and running an applet..
    ... I need to dl a jabber client, has to be an applet that runs on browsers.. ... the few that I have downloaded all they consist of is one jar file.. ... applets have to be embedded in an HTML file to run on browsers.. ... in little applets I have written myself class is in same dir where HTML file is.. ...
    (comp.lang.java.help)
  • Re: downloading and running an applet..
    ... > to be embedded in an HTML file to run on browsers.. ... > jar file, there are tons of classes in there... ... See the "archive" attribute of the applet tag. ...
    (comp.lang.java.help)