7 replies
by basit_jafri
Hi
Your question is toooo short. Please elaborate what are you trying to do. If you mean that u want to use an applet integrated with a response of a servlet then simply print the tag out with the response and store the applet class on the same url so that the class can be picked up by the page becuase the response page is taken to be an HTML by the client browser and it just looks for the class file for the applet if the tag is there
I guess it answers your question , if not, please refraze your question
by shanghai sam
The answer is not completely satisfactory.I hope my question is not correct.
Actually,I have an applet.When I include this applet in response of servlet (present in 'JSDK2.0 servlets' directory and the applet class is also present in 'JSDK2.0 servlets' directory,I am not able to access the applet class.The applet is not loading.I find an error as 'class not found ' in the status bar.
Will U tell me what is the reason?
by bhun_78
The answer is not completely satisfactory.I hope my question is not correct.
Actually,I have an applet.When I include this applet in response of servlet (present in 'JSDK2.0 servlets' directory and the applet class is also present in 'JSDK2.0 servlets' directory,I am not able to access the applet class.The applet is not loading.I find an error as 'class not found ' in the status bar.
Will U tell me what is the reason?
by don_raka
Same as Basit, I presume you want to use an applet integrated with a response of a servlet.
The answer from Basil is correct. But I would like to add some notes. As far I can recall, In JSDK2.0 there's a very lightweight webserver called servletrunner (and you're using it right now, right ?). That servlet runner is only for testing servlet. It can't serve static resource other than HTML.
You should try using another servlet engine that adheres to most recent servlet spec. Tomcat (jakarta.apache.org) or Resin (www.caucho.com) are 2 examples.
There's a standar format in deploying a web app: where you put the servlet class, where you put the HTML, where you put the GIFs, the JSP, etc.
An example is (I'm using Resin, in Windows):
I put the servlets in D:\Resin\doc\Web-inf\com\raka\MyServlet.class. (web-inf dir isn't accesible from browser).
I provide a web-appz deployment descriptor, as an XML file, that defines the mapping of that an URL to that class. (You need one descriptor for one web-app). The root directory of my web-app is D:\Resin\doc\.
There I put my applet class, together with my HTMLs, GIFs, etc. Or anywhere else (in aother dir) as long as it's accesible by browser. Remember, not in Web-inf. It's just forservlets, I think.
About tag, you must be careful about the baseclass URL (the src attribute. Sorry I almost forgot, src right ? I don't develop applets at this time, but speech objects). For sure, try absolute URL first. Than, after you're convenient an becoming an expert in servlet development (and administering a servlet engine, or appz server), you will learn about the intricacies of relative URL in servlet. Read the servlet spec, please, for complete info on relative url.
Good Luck,
Raka
by bhun_78
by bhun_78
THe answer is not completely unacceptable.But still I expected more.I am new to Java field so I don't know about Resin.May I get help for this?I more problem, how to connect database thru applets?
Thank U
Bhuns
by don_raka
Hi,
for sure : class not found means the class (whether it's in jar or a directory tree) can't be loaded from the web server. So it's just a matter of placement. If you put it right, and you set the correct src attribute to the applet tag, everything will be just fine.
About connecting to database from applet :
Usually you would do this by making the applet communicate with another (java) program on the server. It can be applet-to-application (using RMI --- remote method invocation --- it let's two / more java objects communicate to eaach other as if they're in the same address space / process. It dramaticaaly reduce the pain of network programming. You should learn it as RMI is the basic of JINI). Alternatively, you can make appletcoomunicate with servlet, that is applet open URL connection to the URL of servlet, pass the request parameters, and read the response from input stream. It should be easy for you.
But you can access database, over the web, directly from your applet -- if you want to. But one of the drawback is: the driver of that database must be loaded to the client together with the applet. Then, from applet you just open database connection (using JDBC API) as usual. This choice leads to what people say "NOT THIN CLIENT".
In todays world, you will usually pick one of the two options mentioned above, but not the "NOT THIN CLIENT".
One more thing: the sentence "adding applet to servlet" is pottentialy misleading. You don't add applet to servlet.
For Resin info: Please find out by yourself at www.caucho.com
---------------------------------------------
THe answer is not completely unacceptable.But still I expected more.I am new to Java field so I don't know about Resin.May I get help for this?I more problem, how to connect database thru applets?
Thank U
Bhuns
This discussion is closed to new replies.
Trending Web Development posts
Sort by Trending