embed .jar files

P

Pasquale

I have never embedded java files into html pages, and I'm attempting
this for the first time.

I have been given .jar and .jad files to embed. I've been searching and
all I have found that seems to apply to my situation is that the archive
attribute is what I should use for the .jar file? What about the code
and codebase attributes? I don't have any .class files. Should I have
been provided with one or more of those? Do I use the .jad files instead
of .class?

My host's instructions are basic:

1. Upload your Java servlets (classes) into your /WEB-INF/classes/ folder.

2. The path to your servlets is:
http://yourdomain/servlet/servletname

If I can see an example of tags and attributes for my situation, it
would much appreciated!

Thanks,
Pasquale
 
L

Lew

Pasquale said:
I have never embedded java files into html pages, and I'm attempting
this for the first time.

I have been given .jar and .jad files to embed. I've been searching and
all I have found that seems to apply to my situation is that the archive
attribute is what I should use for the .jar file? What about the code
and codebase attributes? I don't have any .class files. Should I have
been provided with one or more of those? Do I use the .jad files instead
of .class?

My host's instructions are basic:

1. Upload your Java servlets (classes) into your /WEB-INF/classes/ folder.

2. The path to your servlets is:
http://yourdomain/servlet/servletname

If I can see an example of tags and attributes for my situation, it
would much appreciated!

<http://tomcat.apache.org/tomcat-6.0-doc/appdev/deployment.html>
 
B

bencoe

I have never embedded java files into html pages, and I'm attempting
this for the first time.

I have been given .jar and .jad files to embed. I've been searching and
all I have found that seems to apply to my situation is that the archive
attribute is what I should use for the .jar file? What about the code
and codebase attributes? I don't have any .class files. Should I have
been provided with one or more of those? Do I use the .jad files instead
of .class?

My host's instructions are basic:

1. Upload your Java servlets (classes) into your /WEB-INF/classes/ folder.

2. The path to your servlets is:http://yourdomain/servlet/servletname

If I can see an example of tags and attributes for my situation, it
would much appreciated!

Thanks,
Pasquale

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application... you can place whatever libraries you want to use here
which can be accessed via your servlets. The servlet itself is sort of
like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.


import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class login extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
String user=request.getParameter("user");// Get info from
forms.

//Perhaps someone is logged in already...Check Cookies.

if(user==null||pass==null){

Cookie[] cookies = request.getCookies();
Cookie temp;


if(cookies!=null)
for(int i=0;i<cookies.length;i++){
temp=cookies;

if(temp.getName().equals("user"))

user=temp.getValue();

if(temp.getName().equals("pass"))

pass=temp.getValue();

}
}


PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println(wrap.runTemplate(""));
out.close();
}


public void doPost(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
doGet(request, response);
}

}

This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder, and access them like
you would in any java application... keeping in mind you use the
response as the output stream.

Ben.
 
L

Lew

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application.. you can place whatever libraries you want to use here
which can be accessed via your servlets.

Neither statement is correct.

You put your web application in a subdirectory in the 'webapps/' subdirectory
of ${CATALINA_HOME}/. That sub-subdirectory has the same name as the
application and is the root of the application. WEB-INF/ is a subfolder of
the application root, not a parent folder.

You do not put your libraries in WEB-INF/classes/, you put them in WEB-INF/lib/.
The servlet itself is sort of like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.

That is quite a stretch. Servlets (and JSPs, which are servlets in disguise)
are really quite different from PHP files.
This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder,

Wrong, WEB-INF/lib/.
and access them like you would in any java [sic] application

No. Your application, which is not like "regular" Java apps, access the
libraries just like an application would access any Java libs.
... keeping in mind you use the response as the output stream.

No, you don't. You use the OutputStream of the response as the output stream.
 
B

bencoe

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application.. you can place whatever libraries you want to use here
which can be accessed via your servlets.

Neither statement is correct.

You put your web application in a subdirectory in the 'webapps/' subdirectory
of ${CATALINA_HOME}/. That sub-subdirectory has the same name as the
application and is the root of the application. WEB-INF/ is a subfolder of
the application root, not a parent folder.

You do not put your libraries in WEB-INF/classes/, you put them in WEB-INF/lib/.
The servlet itself is sort of like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.

That is quite a stretch. Servlets (and JSPs, which are servlets in disguise)
are really quite different from PHP files.
This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder,

Wrong, WEB-INF/lib/.
and access them like you would in any java [sic] application

No. Your application, which is not like "regular" Java apps, access the
libraries just like an application would access any Java libs.
... keeping in mind you use the response as the output stream.

No, you don't. You use the OutputStream of the response as the output stream.

I was trying to explain servlets in a simple to understand manner, and
guess what, it sounds like his sever has set it up so you put your
classes in /WEB-INF/classes, which can be set in the config files,
which can also be set up to auto-deploy any files that show up this
directory.

Also you're probably correct about the lib directory, I usually unpack
jar files and just place them in my root directory.

what's your problem? I'm just trying to help this fellow.

Ben.
 
B

bencoe

like an application would access any Java libs.
No, you don't. You use the OutputStream of the response as the output stream.

Oh, and gee, look at my sample code jackass

PrintWriter out = response.getWriter();

Ben.
 
P

Pasquale

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application... you can place whatever libraries you want to use here
which can be accessed via your servlets. The servlet itself is sort of
like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.


import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class login extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
String user=request.getParameter("user");// Get info from
forms.

//Perhaps someone is logged in already...Check Cookies.

if(user==null||pass==null){

Cookie[] cookies = request.getCookies();
Cookie temp;


if(cookies!=null)
for(int i=0;i<cookies.length;i++){
temp=cookies;

if(temp.getName().equals("user"))

user=temp.getValue();

if(temp.getName().equals("pass"))

pass=temp.getValue();

}
}


PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println(wrap.runTemplate(""));
out.close();
}


public void doPost(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
doGet(request, response);
}

}

This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder, and access them like
you would in any java application... keeping in mind you use the
response as the output stream.

Ben.


Ben,

Thanks for the response, but I'm trying to find out how to have a .jar
file display in a HTML page. See example below, which needs more
attributes. I guess I'm looking for some beginner guidance from where to
upload what files to what tag/attributes I need within my HTML page to
display the file(s).

The above looks like VB/ASP?

For example:
<applet archive="Z3.jar">
<PARAM NAME="archive" VALUE="Z3.jar">
</applet>

Pasquale
 
A

Andrew Thompson

Pasquale said:
I have never embedded java files into html pages, and I'm attempting
this for the first time.

Where did you get these file? Did they come with
instructions? Were Javadocs provided for them?
What is the application?
I have been given ..

By who?
...jar and .jad files to embed.

A quick search on jad file indicates to me that it is more for
packaging applications for mobile phones. Is that you market?
...I've been searching and
all I have found that seems to apply to my situation is that the archive
attribute is what I should use for the .jar file?
Yes.

...What about the code
and codebase attributes?

What about them? Consult that document I linked
and ask further (and smarter) questions if need be.
...I don't have any .class files. Should I have
been provided with one or more of those?

They are most likely in the .jar, which a quick search
should reveal as being a form of Zip archive, but for Java.
It is possible to rename .jar files as .zip and late model
windows will let you browse into them (but they should
be changed back to .jar extension before deployment).

You need to reference the class that is the (or an)
applet, in the applet element of the web page.
That is where the Javadocs mentioned above, come
in handy.
..Do I use the .jad files instead of .class?

No. (Unless the target is J2ME on mobile phones)
My host's instructions are basic:

1. Upload your Java servlets (classes) into your /WEB-INF/classes/ folder.

There are no servlets (directly) involved with applet
deployment. Applets can be deployed in pure HTML,
on a server that has no servlet ability.

Applet deployment is a specialist area that is very
much not for beginners, even most Java pros would
not be able to deploy an applet reliably to an internet
based audience. I suggest you hire a consultant.

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1
 
P

Pasquale

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application... you can place whatever libraries you want to use here
which can be accessed via your servlets. The servlet itself is sort of
like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.


import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class login extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
String user=request.getParameter("user");// Get info from
forms.

//Perhaps someone is logged in already...Check Cookies.

if(user==null||pass==null){

Cookie[] cookies = request.getCookies();
Cookie temp;


if(cookies!=null)
for(int i=0;i<cookies.length;i++){
temp=cookies;

if(temp.getName().equals("user"))

user=temp.getValue();

if(temp.getName().equals("pass"))

pass=temp.getValue();

}
}


PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println(wrap.runTemplate(""));
out.close();
}


public void doPost(HttpServletRequest request,HttpServletResponse
response)

throws IOException, ServletException

{
doGet(request, response);
}

}

This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder, and access them like
you would in any java application... keeping in mind you use the
response as the output stream.

Ben.


Ben,

Thanks for the response, but I'm trying to find out how to have a .jar
file display in a HTML page. See example below, which needs more
attributes. I guess I'm looking for some beginner guidance from where to
upload what files to what tag/attributes I need within my HTML page to
display the file(s).

For example:
<applet archive="Z3.jar">
<PARAM NAME="archive" VALUE="Z3.jar">
</applet>

Pasquale
 
B

bencoe

It sounds to me that what you're trying to do is get a servlet up and
going. If you're hoping to use third party libraries the /WEB-INF/
classes/ folder represents the root directory of your servlet
application... you can place whatever libraries you want to use here
which can be accessed via your servlets. The servlet itself is sort of
like a PHP file, in that it takes care of rendering a web-page on the
fly for a client connecting to it... here's an example of.
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class login extends HttpServlet {
public void doGet(HttpServletRequest request,HttpServletResponse
response)
throws IOException, ServletException
{
String user=request.getParameter("user");// Get info from
forms.
//Perhaps someone is logged in already...Check Cookies.
if(user==null||pass==null){

Cookie[] cookies = request.getCookies();
Cookie temp;
if(cookies!=null)
for(int i=0;i<cookies.length;i++){
temp=cookies;
if(temp.getName().equals("user"))
user=temp.getValue();
if(temp.getName().equals("pass"))
pass=temp.getValue();

PrintWriter out = response.getWriter();
response.setContentType("text/html");
out.println(wrap.runTemplate(""));
out.close();
}

public void doPost(HttpServletRequest request,HttpServletResponse
response)
throws IOException, ServletException
{
doGet(request, response);
}

This is a simple servlet that shows most of the basic functions you'd
probably want to be using, with a bit of code omitted, once you get
something like this up and running, you can put the other libraries
you want to use in the /WEB-INF/classes folder, and access them like
you would in any java application... keeping in mind you use the
response as the output stream.

Ben,

Thanks for the response, but I'm trying to find out how to have a .jar
file display in a HTML page. See example below, which needs more
attributes. I guess I'm looking for some beginner guidance from where to
upload what files to what tag/attributes I need within my HTML page to
display the file(s).

For example:
<applet archive="Z3.jar">
<PARAM NAME="archive" VALUE="Z3.jar">
</applet>

Pasquale


Here's some HTML code I had for embedding an Applet on my server.

<applet code="com.sun.opengl.util.JOGLAppletLauncher"
width=600
height=560
codebase="http://www.mariealighieri.com/Vulgate3D/"
archive="jogl.jar,gluegen-
rt.jar,vulgate.jar,DolphinNet.jar,GameServe.jar,GaveView.jar,GUI.jar,Assignments.jar">
<param name="subapplet.classname"
VALUE="com.Vulgate.View.Vulgate3D">
<param name="subapplet.displayname" VALUE="Vulgate 3D">
<param name="progressbar" value="true">
<param name="cache_archive" VALUE="jogl.jar,gluegen-rt.jar">
<param name="cache_archive_ex" VALUE="jogl.jar;preload,gluegen-
rt.jar;preload">
</applet>

This is HTML code that you can place on any page it has nothing to do
with servlets.

You'd include any archives you want to use in the archive field... to
actually use these libraries, mind you, you would have to write an
Applet or JApplet... This is a Java awt or Swing application that is
designed specifically to be embedded in a website...

So to summarize the process:

- You might have some libraries you plan on using, I don't have a clue
what you're trying to do.
- You would take these libraries and make, I would suggest a Swing
application, you can find lots of tutorials about this on the
Internet.
- Take your JPanel and port it to a JApplet. (pretty simple)
- Take your .lib files used and place them in a directory on your
server.
- Take the .class file that represents your Applet and put it in that
folder.
- Take HTML code like the stuff I put above, the 'code' tag should
point to the .class file. the archive path to all the libraries you
want to use.


This is all assuming you're trying to make some sort of graphical
application, you might be better off learning about servlets if this
isn't the case .

Ben.
 
P

Pasquale

Andrew said:
Where did you get these file? Did they come with
instructions? Were Javadocs provided for them?
What is the application?


By who?

I was sent the files from a colleague who received them from his client.
They are to be displayed on the client's site for preview.
A quick search on jad file indicates to me that it is more for
packaging applications for mobile phones. Is that you market?

Their market is delivering advertisements, video commercials, etc to
PDAs and such within range.
What about them? Consult that document I linked
and ask further (and smarter) questions if need be.

I was wondering what values these attributes would contain.
Reviewing the information in the link you sent helped with that.
Thanks.
They are most likely in the .jar, which a quick search
should reveal as being a form of Zip archive, but for Java.
It is possible to rename .jar files as .zip and late model
windows will let you browse into them (but they should
be changed back to .jar extension before deployment).

You need to reference the class that is the (or an)
applet, in the applet element of the web page.
That is where the Javadocs mentioned above, come
in handy.

I opened the .jar in WinZip and there is a Main.class and other classes
named a - g. There are also several PNG files and a
/meta-inf/manifest.mf file.

So I have attempted to use the below without success. The status bar
states Applet Main notinited.

Thanks for all the info and help!

<APPLET code="Main" archive="Z3.jar" width="176" height="184">
<PARAM name="code" value="Main">
<PARAM name="archive" value="Z3.jar">
<PARAM name="width" value="176">
<PARAM name="height" value="184">
</APPLET>
 
B

bencoe

I was sent the files from a colleague who received them from his client.
They are to be displayed on the client's site for preview.





Their market is delivering advertisements, video commercials, etc to
PDAs and such within range.





I was wondering what values these attributes would contain.
Reviewing the information in the link you sent helped with that.
Thanks.






I opened the .jar in WinZip and there is a Main.class and other classes
named a - g. There are also several PNG files and a
/meta-inf/manifest.mf file.



So I have attempted to use the below without success. The status bar
states Applet Main notinited.

Thanks for all the info and help!

<APPLET code="Main" archive="Z3.jar" width="176" height="184">
<PARAM name="code" value="Main">
<PARAM name="archive" value="Z3.jar">
<PARAM name="width" value="176">
<PARAM name="height" value="184">
</APPLET>

Codebase should point to the directory that the .jar files and classes
are in.
 
A

Andrew Thompson

Pasquale said:
Their market is delivering advertisements, video commercials, etc to
PDAs and such within range.

J2ME deployment is not my area of expertise.
You should be interested more in the JAd files
for that, AFAIU.

..but ask that colleague to send you the (damn)
documentation as well.
So I have attempted to use the below without success. The status bar
states Applet Main notinited.

There is a method important to Java applications
(as opposed to applets) called 'main()' and a lot of
programmers who have no imagination also call the
class that has a main() method, Main.

It might also be a combined applet/application
(which makes the name worse).
<APPLET code="Main" archive="Z3.jar" width="176" height="184">

Is that class in the root of the Jar file, or a
subdirectory? A class that is in (e.g.)
com/our/Main.class should be referred to
as com.our.Main

It is not necessary to repeat attributes from
above, here..
<PARAM name="code" value="Main">
<PARAM name="archive" value="Z3.jar">
<PARAM name="width" value="176">
<PARAM name="height" value="184">

..it simply needs the closing tag, like you have here.
</APPLET>

--
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200706/1
 
P

Pasquale

Andrew said:
J2ME deployment is not my area of expertise.
You should be interested more in the JAd files
for that, AFAIU.

.but ask that colleague to send you the (damn)
documentation as well.

I'm sure he didn't receive anything. I'll ask him to ask the client for
the ?Javadocs?. Does the documentation contain what to use for the
'code' attribute and other necessary embedding info?
There is a method important to Java applications
(as opposed to applets) called 'main()' and a lot of
programmers who have no imagination also call the
class that has a main() method, Main.

It might also be a combined applet/application
(which makes the name worse).


Is that class in the root of the Jar file, or a
subdirectory? A class that is in (e.g.)
com/our/Main.class should be referred to
as com.our.Main

The Main.class and classes a to g are in the root. The only item in a
subdirectory is the manifest.mf file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,830
Latest member
HeleneMull

Latest Threads

Top