Where I save the applet in tomcat? - java

I call an applet through a JSP...where I have to save it? and what the .class and the .java file? in which root in tomcat so when I call it from the JSP to be appeared?
here is the applet call from the jsp
%><%# page language="java"%>
<html>
<body>
<jsp:plugin code="g7appletDialog.class" codebase="" type="applet" width="300" height="200">
<jsp:fallback>Unable to load applet</jsp:fallback>
</jsp:plugin>
<applet code=""g7appletDialog.class"" width="300" heigjt="200"></applet>
</body>
</html><%

The path to your servlet must be relative to your jsp. If you have a jsp in web-inf/admin/pages/index.jsp, then you can place the .class file in directory web-inf/admin/pages/ and just have code="g7appletDialog.class".
In case that you have a central repository for applets, lets say web-inf/admin/applets then you should change the code to code="../applets/g7appletDialog.class".
The ../ gets you one dir back. To go two dirs back use ../../ and so on...

Related

Specifying Image Path File From Another Folder in WEB-INF?

I'm including a separate JSP page (header.jsp) into my current home.jsp page as goes:
<jsp:include page='/WEB-INF/Header/header.jsp'/>
In that header.jsp page, I have an image as follows:
<img id="myImage" src="<c:url value='../Images/myImage.jpg'/>" />
But my image is not displaying on my home.jsp even though all the other elements (i.e. paragraphs, anchor links, etc.) found inside header.jsp is displaying normally on the home.jsp page as it should.
My folder structure goes:
MyProject
WebContent
WEB-INF
Header
header.jsp
Images
myImage.jpg
Views
Home
home.jsp
How do I specify the path file to my image (<img id="myImage" src="<c:url value='?/myImage.jpg'/>" />) from within my header.jsp file?
I seem to have it working:
img src="${pageContext.request.contextPath}/Images/myImage.jpg"
Please let me know if this is an ideal way to go about this in JSP.

I can't import a CSS File in a JSP

I try to add a CSS file to an JSP which is running on tomcat 8. The CSS just changes the appearance of tables. The CSS file is in the same folder as the JSP. I tried using:
<link href="table.css" rel="stylesheet" type="text/css">
but it didn't show any changes. So I tried:
<style type="text/css">
<%# include file="./table.css" %>
</style>
But this gives me a weird error, when I try to reach the page in my browser on the first try I get 404 - Resource not found but when I try again it works. What can cause this and is there an easier way to import my CSS file in the JSP? I use a servlet to reach the JSP if that matters.
Edit:// I just checked the WAR File i exported and the WEB-INF Folder only contains my classes the Folders of the HTML and JSP Sites are on the root directory of the WAR file.
I'd put all your .css files in a folder named /css right under the root of your WAR. The path would be css/table.css.
Same for JavaScript: create a folder named /js right under the root of your WAR. The path to JavaScript is js/foo.js

I want to put my jar file in html code

How can I put my jar file into my html?
I tried to use that:
<html>
<head>
</head>
<body>
<applet code=Tictactoe.class archive="Test.jar">
</applet>
</body>
</html>
My problem is that when Im trying to run my html code java is blocking my jar file.
Try to add your url (local or distant server url) in exception list on java settings panel.

How to add jar into applet?

I have JApplet which use some jars. I have added these jars to lib folder of my applet, have set these to classpath and have created html:
<HTML>
<HEAD>
<TITLE>Applet</TITLE>
</HEAD>
<BODY>
<H1>Applet</H1>
<object classid="java:com.csat.CSATApplet.class"
type="application/x-java-applet"
archive="file:///C:\\Documents and Settings\\alburash\\Desktop\\CSAT_client_2.jar"
height="300" width="450" >
<PARAM NAME=ARCHIVE VALUE="dom4j-1.6.1.jar,poi-3.10-FINAL-20140208.jar,poi-excelant-3.10-FINAL-20140208.jar,poi-ooxml-3.10-FINAL-20140208.jar,poi-ooxml-schemas-3.10-FINAL-20140208.jar,poi-scratchpad-3.10-FINAL-20140208.jar,stax-api-1.0.1.jar,xmlbeans-2.3.0.jar,axis.jar,commons-discovery-0.2.jar,javax.wsdl_1.6.2.v201012040545.jar,jaxrpc.jar,org.apache.commons.logging_1.1.1.v201101211721.jar,org.apache.xmlrpc_3.0.0.v20100427-1100.jar,saaj.jar">
</object>
</BODY>
</HTML>
But when I start this html I see error "java.lang.NoClassDefFoundError:javax/xml/rpc/Service". I understand that the applet can't find this class, but why does it happen? When I start the applet via Eclipse it works correct. All needed libraries are into "lib" folder into CSAT_client_2.jar , classpath is correct, CSATApplet.class have been found(it was my previous problem).
It's unsigned applet.
For Stephen C: I have tried to change html and the applet can't find CSATApplet.class and don't start. When I use my first html, the applet finds CSATApplet.class without problem and starts, but after that I see my first error. My main problem is that I can start applet, but the applet doesn't find jar files with needed libraries.
<HTML>
<HEAD>
<TITLE>Applet</TITLE>
</HEAD>
<BODY>
<H1>Applet</H1>
<object classid="java:com.csat.CSATApplet.class"
type="application/x-java-applet"
codebase="file:///C:/Documents%20and%20Settings/alburash/Desktop/CSAT_client_2.jar"
height="300" width="450" >
</object>
</BODY>
</HTML>
Also, when I start the applet in Eclipse I see warning, but the applet starts and works correctly:
"Apr 30, 2014 2:09:06 PM org.apache.axis.utils.JavaUtils isAttachmentSupported
WARNING: Unable to find required classes (javax.activation.DataHandler and javax.mail.internet.MimeMultipart). Attachment support is disabled."
According to the HTML 4.0.1 spec, section 13.3, the "archive" attribute is a space separated list of URLs. The implication is that it is the list of URLs for the JARS that comprise the applet's classpath.
Consider putting all of the JARs into one directory and using the "codebase" attribute so that you can use relative URLs in the "archive" URL list.
Your "file:" URL is malformed. A well-formed Windows "file:" URL looks like this:
file://laptop/My%20Documents/FileSchemeURIs.doc
or
file:///C:/Documents%20and%20Settings/davris/FileSchemeURIs.doc
Note that:
the path separator in a hierarchical URL is "/", and not "\" or "\",
any space characters need to be %-escaped.
Finally, I could not find any justification in the spec or in the Oracle pages on applets that would support using a <param name='archive' ... > element to specify the applet classpath.
Reference:
File URLs in Windows
You can use applet tag:
<applet codebase="."
code="com.csat.CSATApplet.class"
archive="CSAT_client_2.jar,dom4j-1.6.1.jar,poi-3.10-FINAL-20140208.jar,poi-excelant-3.10-FINAL-20140208.jar,poi-ooxml-3.10-FINAL-20140208.jar,poi-ooxml-schemas-3.10-FINAL-20140208.jar,poi-scratchpad-3.10-FINAL-20140208.jar,stax-api-1.0.1.jar,xmlbeans-2.3.0.jar, axis.jar,commons-discovery-0.2.jar,javax.wsdl_1.6.2.v201012040545.jar,jaxrpc.jar,org.apache.commons.logging_1.1.1.v201101211721.jar,org.apache.xmlrpc_3.0.0.v20100427-1100.jar,saaj.jar"
height="300"
width="450">
</applet>
By this way, both the HTML page and JAR files must have in same directory

Applet war project doesn't find applet class in jar

I have the following projects
>projectJar
>projectWar
Inside projectJar I have a class that extends Applet, the class's name is com.me.test.TestApplet. Then in the war project I include the jar and create an HTML file like the following...
<HTML>
<HEAD>
<TITLE>A Simple Program</TITLE>
</HEAD>
<BODY>
<APPLET code="com.me.test.TestApplet.class"
archive="WEB-INF/lib/projectJar.jar" WIDTH=256 HEIGHT=240> </APPLET>
</BODY>
</HTML>
However, when I try to load the applet I get a class not found exception for TestApplet. Can anyone see what I am missing?
You cannot serve a "PATH" under "WEB-INF". Move your "projectJar.jar" to another folder, perhaps "/jar/porjectJar.jar".

Categories