This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Applets and the fly likes How to run applet in servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "How to run applet in servlet" Watch "How to run applet in servlet" New topic
Author

How to run applet in servlet

Swaroop Reddy
Ranch Hand

Joined: Feb 25, 2009
Posts: 34
Hai,
I have an applet which needs to be called from servlet,but when ever i try its giving class not found exception
I tried in all the ways as given in the Forums but still.......

please help me out to run this I am more in to webbased applications i dont know much about applets,but still i need to run applet in servlet

if possible an example please

Thanks in prior


Mr.Reddy
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Hello "Javacity Reddy"-

Welcome to JavaRanch.

On your way in you may have missed that we have a policy on screen names here at JavaRanch. It must consist of a first name and a last name, and not be obviously fictitious. Since yours does not conform with it, please take a moment to change it, which you can do using the "My Profile" link at the top of the page.

i need to run applet in servlet

This isn't possible. An applet is run in a web browser, while a servlet runs in a servlet container - in other words, they run on different machines.

What may be possible is to use some of the classes that make up the applet as part of the servlet, but without the applet GUI. Whether this makes sense depends on what exactly you're trying to achieve; why don't you tell us more about that?


Ping & DNS - my free Android networking tools app
Vinoth Thirunavukarasu
Ranch Hand

Joined: Dec 18, 2008
Posts: 164

I think the bellow link will help you through example
http://www.hiox.org/bypass/index.php?id=977


Java Best Practices
Linux Best Practices
Amortization Calculator

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

I'm not sure what it means to "run an applet in a servlet", but in any case it doesn't have anything to do with JNLP. Let's pick a better forum for this question... Applets? Servlets? Okay, applets for now until we get clarification.
aditee sharma
Ranch Hand

Joined: Jul 22, 2008
Posts: 182
Not sure what you mean by "running applet in a servlet". You can certainly make Applet and Servlet communicate with each other.
There are at least 3 ways of doing the latter, if that's what you mean.
However, please note that there has to be a very unusual requirement behind doing that and its not done very often.
1) Have the applet make a HTTP connection to the servlet.
2) Have the applet make a socket connection (non-HTTP) to the servlet
3) Using RMI

I made a project in College that was based upon Applet Servlet communication using RMI. There's a Oreilly book that covers this topic very well.
Swaroop Reddy
Ranch Hand

Joined: Feb 25, 2009
Posts: 34
Hello ,

My problem is like I am developing an webapplication using servlets and jsps, in that application i have a dropdown list where when i click one ot the list option,it should take the data from text file and draw the coressponding diagrams as specified in that text file,for this drawing i am using applet.when i am running it seperately it works fine but when i want to integrate it with servlet it is giving "class not found exception",I tried in almost all ways as specified by forums but still.............



Please give me the solution
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Please fix your display name prior to your next post, like you were asked to. Accounts with invalid display names are generally closed.

when i want to integrate it with servlet it is giving "class not found exception"

What does "integrate" mean? Show us the applet tag you're using in the HTML page. Are all required classes and libraries in publicly accessible directories (in other words, NOT inside of WEB-INF)?
Swaroop Reddy
Ranch Hand

Joined: Feb 25, 2009
Posts: 34
Javacity Reddy wrote:Hai,
I have an applet which needs to be called from servlet,but when ever i try its giving class not found exception
I tried in all the ways as given in the Forums but still.......

please help me out to run this I am more in to webbased applications i dont know much about applets,but still i need to run applet in servlet

if possible an example please

Java Plug-in 1.6.0_11
Using JRE version 1.6.0_11 Java HotSpot(TM) Client VM
User home directory = C:\Documents and Settings\Administrator

----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
o: trigger logging
q: hide console
r: reload policy configuration
s: dump system and deployment properties
t: dump thread list
v: dump thread stack
x: clear classloader cache
0-5: set trace level to <n>
----------------------------------------------------

load: class AppletSLD.class not found.
java.lang.ClassNotFoundException: AppletSLD.class
at sun.plugin2.applet.Applet2ClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.plugin2.applet.Plugin2ClassLoader.loadCode(Unknown Source)
at sun.plugin2.applet.Plugin2Manager.createApplet(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8086/SLDViewerDev/graphics/AppletSLD/class.class
at sun.plugin2.applet.Applet2ClassLoader.getBytes(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader.access$000(Unknown Source)
at sun.plugin2.applet.Applet2ClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 7 more
Exception: java.lang.ClassNotFoundException: AppletSLD.class


Thanks in prior
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41155
    
  45
Post the applet tag that you're using in the HTML/JSP page; it's likely incorrect. But change your display name to something valid first, or your account will get closed.
Amit Bathla
Ranch Hand

Joined: Feb 11, 2005
Posts: 51
.


Amit
University of Florida
VineetK Singh
Ranch Hand

Joined: Jun 02, 2009
Posts: 47
Take a look at this line
Caused by: java.io.IOException: open HTTP connection failed:http://localhost:8086/SLDViewerDev/graphics/AppletSLD/class.class

Is your applet class file named class.class, which resides inside the AppletSLD directory?? There's defenitely something wrong with the applet tag you are using to embedd this applet. Post the applet tag you are using or any other method you are using to embedd the applet, then let's see if we are able to help.


Copy Paste is a design error!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run applet in servlet
 
Similar Threads
Unable to run servlet
Applet not initialized error
Issues regarding Applet-Servlet communication
Class Not Found Error
jsp and swing