Suresh Ramanan

Greenhorn
+ Follow
since Feb 08, 2009
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 Suresh Ramanan

hey thank you guys!!
am gonna try them all out!

Suresh
12 years ago
Hi!

I'm working with dates.
At this point, the design is pretty crude and i'm just making an int 01 and incrementing it for the day.

so i wish to print out the dates in YYYY/MM/DD format.
so i wish to get the date as, say, 2011/02/01
but i'm getting it as 2011/02/1

"02" for month is a string, so no issue there
How do i make sure that 01 is displayed as 01 without getting trimmed as 1?

Best wishes,
Suresh
12 years ago
@ Lee Kian Giap
wow that was a really thorough explanation. Thanks for all your efforts.
I get it now.

Best wishes,
Suresh
14 years ago
hi all!

thanks a lot!
but i still am a little hazy!

i understand that finally is mainly used for cleaning up resources.

but how different is scenario 2 from scenario 1?
Scenario 1 does a clean job. fine... what about scenario 2?

when no exception is thrown, will both work the same?
if an exception is thrown, will scenario 2 close the db or not?

Thanks,
Suresh
14 years ago
hi!

i am really sorry.
though there have been threads on this topic in the past, i have not been able to draw a conclusion as to what the significance of the finally block really is.
Please explain.
--------------------------------------------------------------------------
scenario 1:

try{
//open a db connection
//something can go wrong here
}catch(Exception e){
//handle the exception and print stack trace
}finally{
//close the db connection
}

scenario 2:

try{
//open a db connection
//something can go wrong here
}catch(Exception e){
//handle the exception and print stack trace
}

//no finally block here.. this is the calling method code
//close the db connection

------------------------------------------------------------------------------------
Please validate my understanding.

1) After the finally executes (whether or not an exception occurs), the program does not terminate. The control goes back to the calling method. Am i right?
2) If control goes back to the calling method, nevertheless, then what is the need for a finally block? Is it just good design, that improves modularity and maintainability? Or is it a failsafe mechanism for something else that i am missing to understand?
3) Is System.exit() programmatical? In that case, my try block does not have it. But i still would like to know what happens if it does? Will the two scenarios be any different? Will finally save the day for the scenario 1?

Thank you so much.

Suresh
14 years ago
Well! Here goes!
Hi All!
After a tiring, brain ratting fight, i was finally able to solve this problem.

IN A NUTSHELL, THE PROBLEM IS WITH JARS, THEIR LOCATION AND RELATIVE PATHS OF OTHER RESOURCES, IF YOU GET THIS ERROR WHEN DEVELOPING PROJECTS IN AN IDE

I ran into this error as many of my friends at JavaRanch here did.
I was developing my "First Struts Program" (though not officially the first one) via Eclipse IDE 3.2.1
I am using Apache Tomcat 5.5.27
Struts 1.3.10 download

I integrated Tomcat into Eclipse and was trying to get my project work via Eclipse thorugh the Run on Server option.
Earlier, working out another sample project on Tomcat Deployment Directory (as recommended in HFSJ), i had been able to work out the project with ease.
(No WAR-ring and putting it in tomcat/webapps though, all from scratch under tomcat)

In Eclipse, i was creating a "Dynamic Web Project".
If App1 is the name of my project, the folder structure that gets created is a
1)App1/src - where your java code goes
2)App1/src/Libraries - where the jars go
On expanding Libraries, you see 3 folders.
i)JRE System Library
ii)Apache Tomcat Library (depends on the server used, I used Apache Tomcat)
iii)Web App Libraries
3)App1/build/classes - the classes go here
4)App1/WebContent - which has WEB-INF/lib, META-INF and the jsps - WEB-INF has the .tld files, the web.xml and the struts-config.xml as peers to the lib folder.

What I did? (Has a lot of relevance to the errors that arised)
1) I created a package java inside src and put my Action and ActionForm classes here
2) Right clicked the project App1 -> Properties -> Java Build Path -> Add External Jars -> added all jars (struts) here.
Now once you do this, the App1/src/Libraries reloads to show all the libraries that are now added to the project, as peers to JRE and Apache Folders
3) Put my jsps under App1/WebContent

Errors Encountered:
ERROR 1: When i hit index.jsp,(this had a struts html tag in it) by launching the server from Eclipse, i got the org.apache.jasper.JasperException: Module 'null' not found
error. And my tomcat always started with a java.lang.ClassNotFoundException: org.apache.commons.beanutils.Converter error, but i didn't bother as it still started (bad programming discipline, i know )


Solution: I was missing jars, thanks to help at JavaRanch.
But i already had all my jars added to the project's build path!! Here they are, under the src/Libraries folder!!
In a desperate attempt, i copied all the struts jars to the WebContent/WEB-INF/lib folder. But nothing gets reflected here.
Instead the Web App Libraries under src/Libraries got reloaded with the libraries. So it seems that the project is picking up the taglib jars only from this folder.

ERROR 2: Now my tomcat started clean and the index.jsp got rendered perfect. ERROR 1 fixed!!!
When i clicked the link, which navigates to the form, i got the following error:
org.apache.jasper.JasperException: Exception creating bean of class java.CustomerForm under form name CustomerForm
Oh man! This was getting bad!

Solution:Looks like the way the setup expects the .class files is right under the classes directory instead of some other package under classes like classes/java
So it was looking for the CustomerForm.class right under classes and not some directory under classes when they actually existed under classes/java
So i put my .java files right under src and built the project again. Changed path entries in struts-config.xml accordingly.
Now they got picked up right and the CustomerForm got created.

Finally, there were some similar relative path problems with the jsps being referred in struts-config.xml.
When i changed them, everything worked.

I'm sure there's a better way of dealing with this problem as its simply a code-organization problem.
But i just thought i'd update folks on this one solution that i got.

Sorry for making the post too long! Wanted to give all details

Best wishes,
Suresh Ramanan



14 years ago
@ Varun

where had you specified Action instead of ActionServlet?
I have run into a very similar error and i'm going nuts...

Can you please help?
Thanks,
Suresh
14 years ago
hey thanks a lot for the replies..
So am i right when i say, a final variable, if its a reference to an object can only point to that object and no other?
And if anything can be changed at all, its the state of the object unless immutable.
Thanks again
14 years ago
Hi!

I know this is kind of crazy but i read somewhere in Head First Servlets and Jsps that even final variables can be manipulated unless its immutable. (Page 204, Q 4).
Can someone please throw some light on this?

Suresh
14 years ago
Thanks Jothi Shankar Kumar
Thanks a bunch
14 years ago
Thanks a lot for your reply, Evans
That cleared up a lot of stuff for me
14 years ago
Hi

Greetings.
"GET requests can only be bookmarked",
does this mean that POST requests cannot be bookmarked or is it simply useless as they do not have any query string params in the URL as do GET requests?

How does a browser deal with bookmarking POST requests?
Is there any mechanism by which a POST request bookmark is redirected to a GET or stopped from being bookmarked?
Or is this an overhead which the programmer should fix?
Is there a security concern in bookmarking a GET or POST request?

I hope i have not confused by asking too many questions. I just thought i'd ask 'em all together as they were related.

Best wishes,
Suresh Ramanan
14 years ago
First of all, terribly sorry been carried away with work for some months now, didn't check this post for your questions.
I guess its better late than never, so here goes
Thanks to all the hearts for your wishes.

@ Harshana Dias , i cleared the SCWCD with 98%
thought it'd be a li'l modest to not seem like i'm boasting around

@ subha jindal yes i did practice a lot of mock questions..
the one in the HFSJ book gives you a very good standard of what is to be expected from the exam...
it was amazing....
before going to the exam, just have a brush up of all the BANG! questions and infos throughout the book.

@Manikanta, MY bad! i never answered your question but was overjoyed by your success in SCWCD with a whopping 100%. Cheers!!!

Suresh Ramanan
14 years ago
hearty congrats on the feat Manikanta!!!
Amazing job and well done!
and well, i'm the criminal who never answered your question on preparation.
My bad! Sorry been a li'l busy over work that i didn't check the posts on my thread.
But all is well now and i guess nothing to worry.
Rock on!
All the best for your future ventures

Suresh Ramanan
14 years ago