aspose file tools*
The moose likes Applets and the fly likes how to read a value in applet from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Applets
Bookmark "how to read a value in applet from jsp" Watch "how to read a value in applet from jsp" New topic
Author

how to read a value in applet from jsp

bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi,

I have the following code



the code is executing perfectly i.e.,

it is accessing the testapp.class and reproducing the gui which the testapp class has
it is printing the value of the absolute path ( from where the testapp.jsp is running)

now my question is how can i use the string ap( String ap= getServletContext().getRealPath("/"); in the above code) in my applet class so that i can tell where the property file is residing to the properties class.


thank you in advance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
"getServletContext().getRealPath" returns an absolute path that's valid on the server only - the applet wouldn't be able to make use of it.

Any path information the applet needs is best passed via an applet parameter as part of the <jsp:plugin> tag.


Ping & DNS - my free Android networking tools app
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi ulf,

do you mean to make use of codebase in jsp:plugin
i found that codebase is used to tell the exact location of the file.

"getServletContext().getRealPath" returns an absolute path that's valid on the server only - the applet wouldn't be able to make use of it.


i know that "getServletContext().getRealPath" returns an absolute path that's valid on the server only because i tried it in applet and it did not work.

so i passed its value to some String ap, and wanted to acces the value of ap in java code..

is that possible.
thank you

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
codebase has nothing to do with passing parameters to applets; it's used for finding jar files that the applet needs.

Look for something that creates "param" tags inside of the jsp:plugin tag.

i know that "getServletContext().getRealPath" returns an absolute path that's valid on the server only because i tried it in applet and it did not work.

The reason it didn't work is that applets (rather obviously) don't have a servlet context.

so i passed its value to some String ap, and wanted to acces the value of ap in java code..

That's still no good because the path is a server path which has absolutely no meaning or applicability to an applet. Didn't we go over all this yesterday already?
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi ulf,

since ap is returning this i thought of using it from applet.


thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
I give up. Yesterday we talked at length about why it's not possible for applets to access the server file system. I had gotten the impression that you understood that; I won't go over all that again today.
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi ulf,

i understand. but i'm desperate to get the output.

since you said it is possible to write to property file from client which is in same machine as the server ( with signed applets or granting permissions in java policy) i was just trying what else i could do to get the output. i'm desperate.

thank you
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42608
    
  65
since you said it is possible to write to property file from client which is in same machine as the server ( with signed applets or granting permissions in java policy)

Yes, and then you said that this will not be the case during deployment, since there will be multiple applet clients, none of which is running on the server. Which makes this approach useless. So you're trying exactly what we both agreed wouldn't work; I'd say that's a waste of time.
bharani rao
Ranch Hand

Joined: Apr 06, 2009
Posts: 164
hi,
yes, but hmm.

it's ok ulf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read a value in applet from jsp