Mika Leino

Ranch Hand
+ Follow
since Jan 07, 2002
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 Mika Leino


In case you haven't found a solution for your problem then here is one. I needed this very information not long ago and found that the original servlet path can be retrieved from the ServletRequest's parameter "javax.servlet.forward.servlet_path".

Edit: Note, this parameter name works in Tomcat, if you are using a different container then the path can be saved in a different way.
[ February 27, 2007: Message edited by: Mika Leino ]
14 years ago
I'd say C is correct, because the group Any class or interface includes Object. The way I understand option B is "An inner class must extend the Object class.", and that would force us to extend all inner classes from Object.
My problem with that option is that it does not say anything about instances. There is a possibility that two threads request the same servlet, so the container uses different instances for these two threads. They are not executing the same instance's service() method, but I think they are executing the same servlet's service() method.
If the wording would be something like this I would have no problem with that option:
c) The servlet container guarantees that no two threads will execute concurrently in the servlet instance's service method.
I ran into this question in J2EECertificate:
Given that a servlet implements the SingleThreadModel interface. Which of the following statements are true? [Select all correct answers]
a) The servlet is thread-safe.
b) The servlet is distributable across multiple JVMs.
c) The servlet container guarantees that no two threads will execute concurrently in the servlet's service method.
d) The servlet container may create multiple instances of the servlet and dispatch each servlet request to a different servlet instance.
e) The servlet must implement the methods defined in the SingleThreadModel interface.
The answer given is c and d. I think that the c option is if not incorrect then at least ambiguous. If the container creates two instances of the same servlet then as I understand it does not guarantee that only a single thread may execute the servlet's service() method. It does guarantee that two threads will no execute the servlet instance's service() method.
Gabriel, the B option is clearly wrong, and here is why:
On line 1 a new Integer object is created and reference to it is assigned to o. On line 3 that reference is copied to the oa[0]. On line four the reference o is nullified. This does not, how ever, affect oa[0] in any way. Only the reference is nullified, not the object behind the reference.
The reason is choice 2. The signature of JspWriter class is public abstract class JspWriter extends java.io.Writer, and the implicit variable out is an JspWriter. As the translated servlet opens an JspWriter it throws an IllegalStateException.
Once you declare the array size and dimension it cannot be altered any more. In this instance you are trying to put a new array into the first element of the original array. The result would alter the array into two dimensional array.
If you want to have multi dimensional arrays you have to declare it like
int s1[][];
int s2[][][];
I agree with Kaspar on this one. The 11th String object is also eligible for GC after the for loop as there is no reference to it anywhere outside the loop. So considering that code I say the answer should be 11.

The abstract method has no implementation and all concrete subclasses must provide their own implementations of the method.

We're having a problem when we are trying to use Struts 1.1 with WebSphere 4.0.1 Advanced Edition and I'd like to know if some one has been succesful in deploying web applications with such a combination. To make matters worse, due to our client's license the only WebSphere at our disposal is the production server and all development is done on Tomcat 4.1.24.
I tried searching the old posts, but none of them seemed to solve our problem. But then again, I'm no expert on WebSphere. So any help will be grately appreciated.
17 years ago
You aren't missing anything, this is due to the JVM's implementation. In reality JVMs just ignore the attempt to start a dead thread. How ever if you have a question in the exam about re-starting a dead thread, the answer is always "throws a runtime exception".
You could try this page. There are other references too, just type something like "binary decimal number conversion" to Google like I did
When the operand to be shifted is an int only the last 5 bits of the second operand count. If the shifted operator is of type long only the last 6 bits of the second operand are counted.
In the first example the second operand is 35, which is 00000000 00000000 00000000 00100011. The last 5 bit are 00011 which is 3. Therefore the first example works as 12<<3.
In the second example the second operand is -5, in binary 11111111 11111111 11111111 11111011. The last bits here are 11011 which is 27 in decimal. Thus 12<<-5 equals 12<<27.
A top level nested class is not instanciated in the same way as a regular inner class. Try this: