Mohit Jain

Ranch Hand
+ Follow
since Jun 04, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Mohit Jain

Hi Ranchers

I have a JSP having two textbox with "Cancel" and "Submit" buttons. Both buttons are <html:submit> type.

After typing in textbox if we press <Enter> key, the Cancel button is executed. This is because the cancel button is the first button on page and is by default focussed on pressing <Enter> key.

I want the second button ("Submit") to be focussed by default.

My Code is something like -

<html:password property="newPassword"/>
<html:password property="reenterPassword"/>

<html:submit property="bipSubmit" value="Cancel"/>
<html:submit property="bipSubmit" value="Submit"/>

Please suggest how to implement this, I prefer not to use JAVASCRIPT.

Its urgent.
16 years ago
Hi Ranchers

Please refer to following code snippet -



Result - 300.0

I m looking for an answer with two decimal places(300.00), however, I get the result only upto one decimal place.

Can somebody please explain this behaviour of double datatype. How to achieve double precision using this.
Thanks for your response David. Well if we put entire list of records in session is it a good practice?
Please suggest what kinda problems may be encoutered following this.

Is there any better way to do this??
16 years ago
Hi

If we want to retain some attribute values across multiple pages which is a better approach -

1. Declare the required formbean attributes as static.
2. Put the formbean into session scope.

I have a list of records showing on Page1, when user clicks on any record, a few parameters are passed to targetted action class.
I do not want those parameters to be displayed in URL query string.
Also I feel its not a good practice to keep entire record list in session.

Please suggest.. Will it help to keep the records as static arraylist in formbean.
16 years ago
Hi Ranchers

I am trying to create a regular expression for validating a password string for the following given rule -

It must contain atleast any two of following 4 classes of characters -
1. lowercase letters.. a - z
2. uppercase letters.. A - Z
3. digits.. 0 - 9
4. Special characters.. !@#$%^&*()/?><

I m having a hard time creating such regular expression. I am not sure if this forum is the right place to post such problem, but, I will really appreciate if someone can help me with this.
16 years ago
Hi Ranchers,

HFSJ page# 330, Following mock question seems to have wrong answer in the book -

Given:
<%@ page isELIgnored="true" %>
What is the effect?

D. The JSP containing this directive should NOT have any Expression Language code evaluated by the JSP container.

E. This page directive will only turn off EL evaluation if the DD declares a <el-ignored>true</el-ignored> element with a URL pattern that includes this JSP.

As per HFSJ, correct answer is E. But I think correct answer should be D.

Reason - On page# 320 it says - "The page directive takes priority over the DD setting!". Therefore, irrespective of DD if JSP directive turns off EL evaluation, the EL code should not be evaluated by JSP container.

Please explain.
While comparing a reference for null value, out of following two ways which way is better??

obj == null OR null == obj

They say it doesnt make difference when this condition is used all alone, but its better to put null on left side when two conditions are concatenated using && or || like -

null == obj && <some condition>


Please suggest.
In HFSJ page# 308, it says init params can be read in a jsp by using <jsp-file> tag as follows -

<servlet>
<servlet-name>ServTest</servlet-name>
<jsp-file>/index.jsp</jsp-file>
<init-param>
<param-name>level</param-name>
<param-value>10th</param-value>
</init-param>
</servlet>
index.jsp code -
<%= config.getInitParameter("level") %>

But it prints "null". I cant understand why JSP cant read the init param. Please help me understand where I am going wrong.

Question2 -
I put both <jsp-file> and <servlet-class> tags in <servlet> (using Eclipse IDE)and it gives error, its ok if I have only one of them present. Can't we put both of them together in <servlet> tag?
Hi Ranchers

How can we run a project in Tomcat by putting its project directory somewhere else(like under C:\) other than "tomcatxx/webapp" directory.

Thanks
[ January 25, 2008: Message edited by: Mohit Jain ]
17 years ago

Originally posted by vitesse wei:
If you implement the serialization for attributes,when session was migrated to another JVM,those attribute will automatically be serialized the deserialized,you do not need to worry about it,but if you do not implement the serialization for you attributes,then you can use this listener to notified your attribute,and they can get ready before they are migrated and after they are migrated,the listener is a work-around for attribute serialization.
hope help you.



My question is that - How does serialization help the process of attribute migration(with session)??

With non-serializable attributes, what's that extra THING this listener provides which enables attribute migration(within session) without serializability??

I feel these points are not well explained on page#258 in HFSJ.
Can somebody please provide a good explanation for this.
Thanks!!
Hi Ranchers

In HFSJ page# 258 it says something about HttpSessionActivationListener as -

During session migration -

1. If attributes are Serializable, we probably don't need this listener.

2. This listener is mostly used to give attributes a chance to make their instance variables ready for Serialization.

Does this mean that for session migration attributes must be Serializable?? don't we require HttpSessionActivationListener then??

If attributes are not Serializable, will they not be transferred?? and then how does HttpSessionActivationListener fit into session migration??

How does session migration and Serialization relate to each other??

Please help me understand this.
[ December 25, 2007: Message edited by: Mohit Jain ]
Thanks a ton Marc, for a brilliant explanation!!

However, what difference does it make if we get a RequestDispatcher from a 'request' object OR a 'ServletContext'.
Which is the preferred way??? Is it ServletContext?? if yes then why??

Please help.
[ December 24, 2007: Message edited by: Mohit Jain ]
Hi Ranchers

I have two doubts -

1.What's the difference between getting a RequestDispatcher from - 'request' object and from 'ServletContext' object.

2. They say - "You must use the forward slash "/" with the getRequestDispatcher() method of ServletContext". Why is it so??

Please help me understand this.
Hi Ranchers

On page 163 HFSJ, it says -

getServletConfig().getServletContext().getInitParameter()

is same as -

this.getServletContext().getInitParameter()

Which object does 'this' refers to here? If it is ServletConfig object then how come our service()/doXXX() method has an implicit reference to ServletConfig object?

Please explain.
Thanks Christophe and Marc.

I see Tomcat6 is also available. Should I go for Tomcat 5.5 or 6?