File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes JSP - Java applet connectivity Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP - Java applet connectivity Issues" Watch "JSP - Java applet connectivity Issues" New topic

JSP - Java applet connectivity Issues

Bhavana Sasne

Joined: Jul 22, 2011
Posts: 2

I am stuck with few problems related to JSP - Java applet file write and database connectivity issues.
1) Calling the applet class from JSP works in the web browser. But the file write code written in applet does not work when called from JSP ( It works if the program is separately executed as a Java applet).

2) Also java database connectivity works when executed from Java applet separately, but does not work when called from JSP.

Tried the following things to make this work, but no success:-
--> According to Tomcat Security Manager
" The security policies implemented by the Java SecurityManager are configured in the $CATALINA_HOME/conf/catalina.policy file. This file completely replaces the java.policy file present in your JDK system directories "
So granted permission to the folder where file is to be written using in catalina.policy file of tomcat, but still does not work for JSP

Please help if anyone has come across this issue.

Paul Clapham

Joined: Oct 14, 2005
Posts: 18115

All of that is rather confusing, but my general impression is that you don't understand that a JSP runs on the server and an applet runs on the client. Therefore if a JSP tries to write to a file (which is a bad practice), it writes to a file on the server, and if an applet tries to write to a file, it writes to a file on the client.

As for database connectivity, apply the same principle. JSP runs on the server, applet runs on the client.
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 39541
Applest are restricted in what they are allowed to do; file I/O is an area applets can't do, unless they are signed. See for details.

Tomcat and its security manager have nothing to do with the applet's permissions.

Ping & DNS - updated with new look and Ping home screen widget
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 60046

To understand how JSP works, please read this article.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bhavana Sasne

Joined: Jul 22, 2011
Posts: 2
Thank you everyone for the information. After the Jar signing it works ..
I agree. Here's the link:
subject: JSP - Java applet connectivity Issues
Similar Threads
Writing a file and executing
jdbc connectivity through applets
-security option on tomcat 5 when run as service
java database connection