Srinivas Kumar

Ranch Hand
+ Follow
since Jul 14, 2005
Merit badge: grant badges
For More
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 Srinivas Kumar

If your question is from where, then the answer is you can call it either from Servlet or from jsp.
Sorry for pulling out old threads, but I need clarification regarding the query.

${requestScope[interger] ne 4 and 6 le num || false}

doesn't requestScope[interger] evaluate to 3

Here is my reasoning for answer as 'false'

requestScope[interger] evaluates to 3. Since 3 is not equal to 4, it evaluates to false.

6 le num also evaluates to false since EL does automatic conversion from String to numeric,

the result is: (false and false || false) resulting in output as false.

is my reasoning incorrect. please explain
Huh!! This discussion caused more confusion. I didn't quite get when IllegalStateException will be thrown.

What do you mean by committing a response exactly? isn't it printWriterObject.println() or outputStreamObject.write()

Servlet 1 : Used getWriter and println method, followed by forward method. This did NOT throw any error.
This would not throw an error as you have not committed your response. Try calling forward after committing your response(by closing the writer), and it should throw exception.
Generally we close the writer in finally statement but before that itself we handle the control to another servlet.So I felt that, in this case, after println followed by forward method should throw the exception, but as per the above statement it didn't throw exception. Can somebody explain in detail?

Servlet 2 : Used getOutputStream and write method (no flush method), followed by forward method. This threw the above stated error.
Do you use getWriter() in your forwarded servlet. If yes, then you would obviously get this error as you have already called getOutputStream on the response object in the forwarding servlet.
Based on my understanding in the first case, it should throw exception in this case as forward method is invoked after write method. In this case again, by write method I assume that response committed and hence the exception.

Servlet 3 : Used just getOutputStream (no write and no flush method), followed by forward method. This threw the above stated error as well.
As per my understanding, just getting an OutputStream object does not necessarily mean committing the response, then why did we get exception in this case? Moreover, no write method and no flush method used before forwarding to the servlet. please explain
"option D - The JSP containing this directive should not have any EL code evaluated by the JSP container."

I got exactly the same doubt as you got when I was going through HFSJ. Thanks for the posting.
I guess the option D is correct. I read the phrase for option D many times to understand it correctly and what I felt was that it didn't say that the JSP should not contain EL code rather it says that JSP code should not have it evaluated by the JSP container. Here "should not" refers to the evaluation by the container but does not mean that "JSP should not contain the EL code". Please let me know if somebody thinks otherwise.
I guess, you might have been confused a little bit with the new window.Simple example is that when you right click and select 'Open in new window' from a page in session, the new request from the second window will get the same session.
Hi, I have been preparing for SCWCD and following HFSJ.After doing the test after each chapter, how do you guys generally decide to go to the next chapter? I mean if you get low score on the test after each chapter, you just review the wrong answers and pass on or you would go through the entire chapter again, then do the test and pass on after getting a good score. Appreciate your suggestions.
For question No.3, Answer should be A,D,E.
Binding listeners need not be declared in DD.
I want to execute a linux script from my java program residing on a windows machine. Can anybody help me in this regard? I can use the other tools like telnet to connect to linux machine and execute scripts but I would like to do it from the java program without going through the tools.
Appreciate your suggestions
I found some strange things.The servlet class file (not source file) is there in my workspace (c:\workspace\<myappName>\build\classes)and nowhere tomcat server is totally in differnt path.The serlvet mapping in web.xml has the url pattern "/<somepath>".How come at runtime my application could find the servlet class without copying the servlet class file on to the server (i mean deployment)? I'm using Eclipse as IDE.Does Elipse do it automatically? If so, where does it place the class file? I searched my entire C: drive for the class file but could not find it.
15 years ago
I have some problem in reading the properties file from servlet.I'm using apache tomcat server. Following is the code snippet.I tried putting the properties file in all possible places(classes, webApps, in the context path) but the application failed to load it.It is giving nullpointer exception at prop.load(is);
public class LoadProps {

public Properties getProps() {
String propertyfile = "";
Properties props = new Properties();

try {
is = this.getClass().getResourceAsStream(propertyfile);
}catch (Exception ioe) {
return props;

Appreciate your help
15 years ago
If your try-catch block does not contain code, then you cannot catch any checked exception.
Thanks Srini. I got it.
class Knowing {
static final long tooth = 343L;
static long doIt(long tooth) {
System.out.print(++tooth + " ");
return ++tooth;
public static void main(String[] args) {
System.out.print(tooth + " ");
final long tooth = 340L;
new Knowing().doIt(tooth);

Output is 343 341 340

Always local variable is of high priority than that of instance or class level variables.
So 340 gets passed to the method and gets incremented by 1 in doIt() method and prints it.
In java, variables are passed by value. So the value of tooth in main will not get reflected (Also note that it is a final variable).So finally 340 gets printed.