Mark Nicholas

Greenhorn
+ Follow
since Jul 22, 2002
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Mark Nicholas

Actually it hangs because when the server throws a 500 the 'is' stream variable is null and I forgot to wrap the is.close() with a checking if is != null. Otherwise your right on the money.
Thanks
This is probably a more low level error handle question:
The following code is used to get the contents of multiple url's, however when the server returns a 500 response code the program exits:
So my question is how do you contine / handle the 500 exception more gracefully ?
java.io.IOException: Server returned HTTP response code: 500 for URL: http://www.some.url
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:691)
at java.net.URL.openStream(URL.java:955)
at com.jm.utils.UrlReader.<init>(UrlReader.java:36)
at com.jm.prj.webgrab.ex01.WebGrabEX01.grab(WebGrabEX01.java:42)
at com.jm.prj.webgrab.ex01.WebGrabEX01.main(WebGrabEX01.java:29)

[ October 08, 2002: Message edited by: Mark Nicholas ]
[ October 08, 2002: Message edited by: Mark Nicholas ]
[ October 08, 2002: Message edited by: Mark Nicholas ]
I would like to use icons on my Jtree nodes which are composed by overlaying two or more icons, any ideas folks ?
Mark
21 years ago
Enjoy, pass a string as the filepath, then get the contents of the file via getFileContent() which returns a stringbuffer. To create a string call
the toString() of the stringbuffer object. This code is really fast !!

[ August 20, 2002: Message edited by: Mark Nicholas ]
[ Edited by Dave to format code ]
[ August 20, 2002: Message edited by: David O'Meara ]
21 years ago
Hi All,
I've got this method to determine the file size if I compress the file, I'm just wondering is there a better way ?
Also note that out.closeEntry(); must be called before you can obtain the size using getCompressSize() otherwise you get -1 ?
public static long getCompressSize(String file)
{
long compsize = 0;
byte[] buf = new byte[1024];
try
{
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("temp.zip"));
FileInputStream in = new FileInputStream(file);
ZipEntry ze = new ZipEntry("dummy");
out.putNextEntry(ze);
int len;
while ((len = in.read(buf)) > 0)
{
out.write(buf, 0, len);
}
out.closeEntry();

// need to close the entry before
// you can obtain details
compsize = ze.getCompressedSize();
in.close();
out.close();
}
catch (FileNotFoundException e){}
catch (IOException e){}
return compsize;
}

[ August 20, 2002: Message edited by: Mark Nicholas ]
21 years ago
Simon,
That sounds great, when I said I knew about filter, a passing glance.
Thanks for all your advice.
Mark
21 years ago
JSP
Piyush,
This is what I had in mind, I'll give it a try later.
Thanks
Mark
21 years ago
JSP
I know about filters, but what I'd like to achieve is compress the output: 1) strip away whitespace, and linefeeds 2) possible gzip compression.

Thoughts ?
21 years ago
JSP
Thanks, I was just wondering if it could be achieved without setting a variable, but that method would certainly work.
Cheers
Mark
21 years ago
JSP
I have an JSP include question: Imagine you have 4 JSP's a.jsb, b.jsp, c.jsp each of which include the menu file m.jsp. In m.jsp are links to a,b,c jsp.
However in good UI design the page your actually on should have it's link disabled. Hence my question: a.jsp includes m.jsp, but is it possible for the included m.jsp to 'know' which file it is being included in ?
Mark
21 years ago
JSP
Thanks Simon, that sounds a logical solution.

Mark
21 years ago
JSP
Is it possible to modify / filter the output of the JspWriter for a JSP page such that some transformation can take place before the output is sent to the client browser.
21 years ago
JSP