A static image served by a web server is a read-only URL. If you want to save images, then you need to send the image data to an active server-side component (like a servlet) over HTTP. That component can then save the image data on the server.
Thanks a lot..I will try that.. But in case if it a stanalone Applet.. Then how to save an image to the server machine..
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
posted
0
Ulf,
Now it's working fine. But please assit me how to save an image now. My Application is struts and the applet class is out of WEB-INF directory, Then how can I pass the image from applet to jsp or servlet.
Please assit me
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35429
9
posted
0
Do you mean a stand alone application? (Applets are running inside of web browsers.) They can use any means supported by the server - HTTP upload, WebDAV, FTP, shared directory, etc. - depends on what's available.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35429
9
posted
0
Then how can I pass the image from applet to jsp or servlet.
The applet can make an HTTP POST to a servlet, and in that call send all data needed to reconstitute the image file.
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
posted
0
But in my it's a struts application. Also my applet class are out of WEB-INF Folder.. So Don't know how to call the struts handler.. Please help
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35429
9
posted
0
Yes, there are two parts to it - the applet would contain code that makes the HTTP call, and the web app would contain code (a servlet or a Struts action) that receives the binary data sent by the image.
I suggest to start by writing an applet that makes a successful HTTP call to a servlet (or Struts action); you can worry about sending the actual image data once you have that.
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
posted
0
Am trying to access a action from the applet using
URL urlServlet = new URL(getCodeBase(), "Dummy.do");
getCodeBase() - Is returning Nullponiterexception.
Any suggestion please.
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35429
9
posted
0
Are you running the applet off a server? Meaning, does the URL in the browser start with "http"? Otherwise there's no code base that could meaningfully be returned.
Meet Gaurav
Ranch Hand
Joined: Oct 08, 2008
Posts: 492
posted
0
After placing URL urlServlet = new URL(getCodeBase(), "Dummy.do"); in the init() it's working..
Anyway to change the getcodebase() value ? Because am placing my applets in a different folder am getting that folder name too appended in the url
Thanks..
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35429
9
posted
0
If the servlet has a different URL (which is quite likely), you can pass that URL to the applet through an applet parameter. That's a good idea anyway instead of putting any part of the servlet URL in the applet code.