Basically, what I am sending to the server is a byte array that is a picture
taken from a cell-phone camera. My client-side code looks like this:
url = new URL(urlString);
connection = (HttpURLConnection) url.openConnection();
connection.setDoInput(true);
connection.setDoOutput(true);
connection.setUseCaches(false);
connection.setRequestMethod("POST");
dos = new
DataOutputStream(connection.getOutputStream());
dos.write(Global.rawImage);
dos.close();
Now what I need the server to do, is to write this image to a file in the
directory /webapps/geosim/DRimages/. Here is what I have:
doPost:
try {
DataInputStream is = new
DataInputStream(request.getInputStream());
raw = new byte[800000];
for(i=0; i<800000; i++)
raw[i] = '\0';
i = 0;
len = 0;
while((i = is.read(raw)) != -1) {
}
file = new File(filePath + d.getTime() + ".jpg");
fos = new FileOutputStream(file);
fos.write(raw);
fos.close();
file = new File("../webapps/geosim/gen-html/DR.html");
fos = new FileOutputStream(file, true);
tag += new String(" \"./DRimages/" " + d.toString() +
"::::" + coordsStr
+ "</img><br>\n");
fos.write(tag.getBytes());
fos.close();
You can ignore the coordsStr for now, that will be null until I find a way
of dealing with embedding the lat/long in the digital image. Basically I
just want to write the image to the server-side directory
TOMCAT_HOME/webapps/geosim/DRimages/
Could you guys help show me how to do this using the ServletContext resource
handling? I'm unfamiliar with how to do this.
mgainty wrote:
>
>
> post the code and we'll walk you thru it
>
> no sweat
> Martin
> ______________________________________________
> Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
>
> Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene
> Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte
> Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht
> dient lediglich dem Austausch von Informationen und entfaltet keine
> rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von
> E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
> Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le
> destinataire prévu, nous te demandons avec bonté que pour satisfaire
> informez l'expéditeur. N'importe quelle diffusion non autorisée ou la
> copie de ceci est interdite. Ce message sert à l'information seulement et
> n'aura pas n'importe quel effet légalement obligatoire. Étant donné que
> les email peuvent facilement être sujets à la manipulation, nous ne
> pouvons accepter aucune responsabilité pour le contenu fourni.
>
>
>
>
>> Date: Thu, 28 May 2009 14:51:28 -0700
>> From: [email protected]
>> To: [email protected]
>> Subject: RE: Debian Tomcat Fail
>>
>>
>> Sorry, this code was provided to me by a graduate student (I'm a lowly
>> freshman). Still very new to all of this, I'll look into that.
>>
>>
>> Caldarale, Charles R wrote:
>> >
>> >> From: trojansnake12 [mailto:[email protected]]
>> >> Subject: RE: Debian Tomcat Fail
>> >>
>> >> File myGifImage = new
>> File("../webapps/geosim/WEB-INF/images/test.jpg");
>> >
>> > Very bad form. The servlet container (Tomcat) is under no obligation
>> to
>> > provide *any* access to the underlying file system (if there is one),
>> > other than to a scratch area. You should be using
>> > ServletContext.getResourceAsStream() rather than expecting File objects
>> to
>> > work.
>> >
>> > - Chuck
>> >
>> >
>> > THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE
>> PROPRIETARY
>> > MATERIAL and is thus for use only by the intended recipient. If you
>> > received this in error, please contact the sender and delete the e-mail
>> > and its attachments from all computers.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [email protected]
>> > For additional commands, e-mail: [email protected]
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Debian-Tomcat-Fail-tp23734947p23770783.html
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>>
>
> _________________________________________________________________
> Hotmail® has a new way to see what's up with your friends.
> http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009
>
--
View this message in context:
http://www.nabble.com/Debian-Tomcat-Fail-tp23734947p23820223.html
Sent from the Tomcat - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]