RE: Insert PNG File from Servlet no go
Andrew Watson <[email protected]> Tue, 28 Jan 2003 12:12:50 +1100
| Newsgroups | gmane.comp.java.jgenerator.devel |
|---|---|
| Message-ID | <[email protected]> |
I finally managed to reproduce the error!
By setting the filename in the jgenerator object to
"http://www.obsidian-studios.com/servlet/Picture"
rather than
"http://www.obsidian-studios.com/servlet/Picture?portfolio_num=1&picture_num=1"
... my guess is that you meant to have the url as something like
"http://www.obsidian-studios.com/servlet/Picture{Some_jgen_var}"
which for some reason is not working correctly, or even
"{picture_url}"
which is being set to the wrong value for some other silly reason.
or you forgot to add the jgen var to the filename or some other variation (let us all know which so we can chuckle)
Double check the filename you are passing to your "InsetPngFile" object, fix that and all should be well.
Andrew
-----Original Message-----
From: William L. Thomson Jr. [SMTP:[email protected]]
Sent: Saturday, January 25, 2003 5:16 AM
To: Andrew Watson
Subject: RE: [Jgen-devel] Insert PNG File from Servlet no go
On Fri, 2003-01-24 at 00:22, Andrew Watson wrote:
> Only other thought is that the url is not being processed correctly...
That would be strange.
> I mean "http://www.obsidian-studios.com/servlet/Picture" is not the
> full url surely (or is picture the servlet, or did you replace the
> picture name with that)? If there is a space in the url, try encoding
> it with %20.
No spaces and yes that is the correct URL less params. Did you expect
some cute and akward name. Picture makes sense to me.
Anyway the full URL with params is
http://www.obsidian-studios.com/servlet/Picture?portfolio_num=1&picture_num=1
Watch out for line wrap.
The same servlet can also be found on my dev server
http://dev.obsidian-studios.com/servlet/Picture?portfolio_num=1&picture_num=1
> Unfortunately at the moment I only use the offline jgenerator mode, so
> I probably don't get the same errors, but I know when I tried
> "http://127.0.0.1/png pics/lgc202.png" it gave an error, but when I
> tried "http://127.0.0.1/png%20pics/lgc202.png" it worked just fine.
That makes sense, but I do not believe my problem has anything to do
with URL encoding. Although I could be wrong. I hope I am so I can get
this problem resolved and move on.
I have alway been an online type of guy. I need to do more using offline
than I do. But that would require a daemon or some thing. As the offline
generation would need to be invoked as part or the client updating data
in the database via our Java management software.
At the moment when that takes place, no communication takes place with
the web and java servers. Thus needing a daemon or something.
> Because of the above limitation, it may take me awhile to track down
> your error, but by all means send it along and I will have a look at
> it.
No worries I appreciate the help. If you need access to online let me
know, I have it on my dev and www servers. I can give you temp shell
access as well if need be.
Basically what ever assistance I can provide to help you help me. Sounds
reasonable.
Sorry for having to bother you with a simple task like this. The hard
stuff I can usually figure out. I stumble and fall on the easy stuff.
Also for security purposes I can't send out the entire servlet that I am
using, but I can include the important part. It's a small servlet to
begin with. The only part not included deals with connecting, querying,
and closing the connection to the database.
if(result_set!=null) {
try {
if(result_set.next()) { // Move to the first record
//PrintWriter print_writer = response.getWriter();
ServletOutputStream sos = response.getOutputStream();
response.setContentLength(result_set.getString(1).length());
if(result_set.getString("FILE_NAME").indexOf("jpg")!=-1) response.setContentType("image/jpeg");
else if(result_set.getString("FILE_NAME").indexOf("jpeg")!=-1) response.setContentType("image/jpeg");
else if(result_set.getString("FILE_NAME").indexOf("png")!=-1) response.setContentType("image/png");
else if(result_set.getString("FILE_NAME").indexOf("gif")!=-1) response.setContentType("image/gif");
sos.write(result_set.getBytes(1));
sos.close();
//print_writer.println(result_set.getString(1));
//print_writer.close();
}
} catch (SQLException sqle) {
System.err.println("Picture Servlet Exception\nCould not retrieve the picture from the ResultSet object :\n"+sqle);
}
}
The commented out lines are what I used to use, prior to Dmitry's
suggestion. I may go back, I'm not sure if there is a difference or
reason to use one over another?
Thanks for your assistance.
--
Sincerely,
William L. Thomson Jr.
Obsidian-Studios, Inc.
439 Amber Way
Petaluma, Ca. 94952
Phone 707.766.9509
Fax 707.766.8989
http://www.obsidian-studios.com
__________ Information from NOD32 1.352 (20030127) __________
This message was checked by NOD32 for Exchange e-mail monitor.
http://www.nod32.com
-------------------------------------------------------
This SF.NET email is sponsored by:
SourceForge Enterprise Edition + IBM + LinuxWorld = Something 2 See!
http://www.vasoftware.com