Richard Agnes

+ Follow
since Feb 12, 2001
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Richard Agnes

I just downloaded the trial of Weblogic 5.1. I want to deploy my web-app which has a few .properties files used in conjunciton with ResourceBundle.getBundle("src") calls. Where should these be located in the directory structure if the servlet is mapped to a url pattern? Should they be in the same directory as the servlet classes? I keep getting a resource not found error.
Help appreciated.
21 years ago
Just North of Sydney, Australia. Overlooking the hawkesbury river...beautiful!

when do i stop being a greenhorn
21 years ago
"This sentence is false."
- some textbook.
21 years ago
how do we model a java interface in UML class diagram?
is it a generalization? association? other...
I am a university student, we have been studying UML fairly intensely for the past year. We also happen to use Larman as our primary textbook, for analysis at least anyway.
I am looking for advice on material with a more refined process, such as RUP (which only seems available for a lot of money on the web). What are the thoughts on Larman anyway? Is this book considered 'a process' by industry standard or merely an introduction to the UML notation. Does UML have it's place in XP? I know little of XP but have heard good things of it is it worth pursueing this avenue instead of RUP or the like?
Secondly Case tools, in particular Rational Rose, does anyone know where I can see some good examples of java based models? I have access to RR2000 at uni and am interested in using this software to develop my own models, I find looking at more experienced developers work extremely beneficial.
all discussion welcome.
I am just new to servlets having just set up environment the other day. In my doPost Method of an HttpServlet I have:
switch (err)
res.sendError(HttpServletResponse.SC_BAD_REQUEST, "information already on file");
res.sendError(HttpServletResponse.SC_BAD_REQUEST, "information not on file");
however when the code executes I get a page not found error instead of the error message, could someone suggest why, is it something to do with my configuration?
edit: I just noticed that the error page does have the correct error code. does this mean IE 5.0 only has a generic message?
thanks in advance.
[This message has been edited by Richard Agnes (edited July 12, 2001).]
21 years ago
I am trying to set up my environment to do the java tutorial on servlets. I have done the following:
1. downloaded, unzipped and installed tomcat 3.2 & apache
2. downloaded the mod_jk.dll and put it in apache module directory
3. changed my classpath to include the servlets.jar
4. set environment variables for TOMCAT_HOME & JAVA_HOME in autoexec:
set TOMCAT_HOME=C:\jakarta\tomcat
set JAVA_HOME=C:\jdk1.2.2
5. in httpd.conf - Include \jakarta\tomcat\conf\mod_jk.conf-auto
then I try to run by:
1. start tomcat - works.
2. start apache - says mod_jk running or similar.
3. enter http://localhost:8080/bookstore (bookstore.war in webapps dir of tomcat)
4. I get to the bookstore.html page and trouble begins.
If apache is running I get a 404 error trying to "start shopping" which I think starts the catalog servlet.
If apache is not running and tomcat is doing the work, the page comes up but after a long time, and tomcat window logs an IOException ( Socket write error ).
It might be worth noting also, that tomcat is the homepage even when apache is running, I don't know if that is right or not?
Has anyone run into similar problem? I searched java.sun but all requests like this receive 0 reply.
thanks in advance.
21 years ago
hi padmini,
to add the 126 + 127 just do it normally, they get promoted to int so answer is 253. Do you know how to convert to binary from dec? if not you should review on web somewhere.
Anyway 253 int value in binary code is:
00000000 00000000 ... 111111101 in the low byte
now since it's truncated to a byte again, we only take those last 8 digits and as you know byte is a signed type, so high bit represents sign and the other 7 bits represent the magnitude. Since high bit in this case is 1 the number is negative. Then you just follow procedure to get magnitude, flip bits and add 1.
11111101 becomes
00000010 then + 1
00000011 this is 3 so the number was -3.
does that make sense? don't bother with adding in binary form if you're unsure how to do it, just work out in decimal and then convert the answer to binary.


public class jsource
public static void main (String argv[])
new jsource().aMethod();
}catch(Exception e)
}catch(IOException e)
//not reachable
void aMethod () throws IOException
throw new IOException();

IOException is a subclass of Exception. The rule is that the exception is caught in the first catch handler, therefore the second catch in this example is unreachable since the exception is caught by the first catch block. The compiler gives this error. Generally, more specific exceptions should be handled first.
I am a little confused still.
in your code you are casting the array 'element' to a MyClass object, I am presuming this would obey the normal rules for casting between classes.
I think the book is talking about the casting of an entire array to a single non-final class identifier. I may be corrected here.
So in the case of your code it would appear:
SuperClass d[] = new SuperClass[10];
MyClass e = (MyClass) d ; //I presume the 'a' was a typo
just to clarify my point, the other row in the table specifies that to cast an array (old-type) to an array (new-type) the elements must be type castable, this suggests the original element is indeed an entire array as this rule makes sense under those conditions.
here's more code to illustrate my second point about casting of interfaces, which according to the book an interface (Old-type) can never be cast to an array (new-type):
void test()
Object o[]=new Object[10];
Serializable b=o; //b is an interface reference
o=(Object[])b; // this line compiles.
help appreciated.
i think you're right, though don't forget the automatic promotion rules when looking at expressions, it seems most smaller than int expressions will promote to size int, so usually answer will be int, long, float, double, unless you're dealing with a single term ( I may be corrected here )
I would answer b could be byte, char, short, int, float, double.
An interesting question would be
char, int, float, double.
just include all types bigger than the smallest type of the result.

hi trevor,
253 as short is a signed binary digit in 2's complement,
making it:
00000000 11111101
then because byte is considered signed also the value of the truncated low order byte here is:
11111101 note the high position is 1 this means negative.
easiest way to convert 2's comp is flip the bits and add 1.
so it becomes
a. 00000010
b. 00000011 //this is 3 so value was -3.
you were on right track, just need to review binary representation.

I agree you cannot cast a Non-final class to a non-final class unless one extends the other.
hi albert,
static code is executed first and in the order it appears in the source so the order goes like this:
static String m = msg("1"); //executed first at class load time.
m = msg("3"); // then it executes this static block
3. Then when you create instance it goes back and executes the
non-static block, it's worth noting the ';' in line 1 above:
m = msg("2");
hope it clears it up.

I too am having trouble with casting.
I have RHE book and refer to table on p121:
it says to cast an array(Old-type) to a non-final class(New-type), Old-type must be object. Is this backwards? Shouldn't it be new type should be object. Similarly casting a non-final class (old-type) to an array (new-type) it says new-type should be object, this seems backward to.
Also why can I auto-convert an array to Cloneable or Serializable interface, yet casting an array to an interface is always error? why not:
Serializable g = (Serializable) someArray;
or is this table supposed to outline only those situations where cast is necessary and not those situations where cast is redundant?