SunQuest
           Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old August 29th, 2002, 07:10 AM
bkhendershot bkhendershot is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Location: Ohio
Posts: 0 bkhendershot User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Servlet security and finding path to server....

Hi. I am relatively new to servlets and have a couple of questions. From what I understand a servlet can create files on the server as long as its from the web address at which it originated. Is that correct? Here is the reason that I ask.

I have some applet/servlet communication. In the applet, users can draw a picture (much like paint). When they are finished, the applet sends the picture to the servlet. I then need the servlet to create a new file in a specified folder and save the picture to it. Originally, I was using Tomcat 4.0.3 on my computer running as a local host to test my code. Using getServletContext.getRealPath("/") I was able to get it to work.

Now I have a web host that is running Apache JServ. They give you a "servlets" folder to load your servlet into and it should work from there. The servlet is communicating just fine, but getRealPath("/") now returns null. I've also tried getResource("/"), but that pulls a Server 500 error.

If anyone can tell me if what I'm trying to do is possible and can offer any other suggestions, I'd really appreciate it. Thank you all in advance.

Reply With Quote
  #2  
Old August 31st, 2002, 04:05 AM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
As far as I know, permission to write to the disk is controlled by the operating system, and determined by the user the App server is running as. There's not guarantee in a server environment that the App server user would have access to the disk.

From the javadoc for ServletContext.getRealPath()
Quote:
This method returns null if the servlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).

I don't know if that applies to you or not.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Servlet security and finding path to server....


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway