Amin Mohammed-Coleman

Greenhorn
+ Follow
since Oct 18, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Amin Mohammed-Coleman

Make sure your SubmitAction class extends Action. Can we see your Action class?
19 years ago
I would use Struts and Tiles framework and for the core logic use spring. So let spring handle the database stuff and Struts handle the controller and view aspect of the application. There are some good tutorials out there for both struts and spring. Spring in Action is a really good book when it comes to spring. i definitely recommend that book. Hope that helps.
The == operator is normally used to compare object references, that is, if 2 references are pointing to the same object on the object heap.

So the first result is false because they are not referring to the same object. Whereas the others are true because the contents are the same. The equals method looks at content rather than object reference.
I'm currently trying to use a javascript pop up date picker with my struts app. The only problem is that the pop -up calendar requires the following:
<input type="text" name="startDate">

whereas I am using ActionForms and therefore my page looks something like this:
<html:text property="endDate" name="multiProductBean"/> and this is causing the problem. Has anybody implemented a pop up date picker using Struts? If so can you point me to an implementation?

Thanks
Amin
19 years ago
In the code where you perform the database insert, do some checking to make sure that records already exists. if it does then ignore the request...
e.g.

If (!recordName exist)
{
perform insert
}
else
{
//do nothing
}

I have encountered the same problem and approached it this way. The other alternative is to use the Struts framework and implement the Token pattern. See The Struts Framework by Sue Spielman
19 years ago
JSP

Originally posted by Priya Balaraman:
Right. Starting off with the 1.4 seems correct. Bought Khalid mughal and starting off preparation.



I've found this book to very useful and easy to understand
Sun Certified Programmer & Developer for Java 2 Study Guide (Exam 310-035 & 310-027) By Syngress, Kathy Sierra (Editor), Bert Bates (Editor)


Thanks

Originally posted by bhavesh bhanushali:
the following code will reflect some light on the issue

public class ByteToString
{
public static void main ( String args[] )
{
Byte b1 = new Byte ( "127" ) ;

if ( b1.toString ( ) == b1.toString ( ) ) // ( 1 )
System.out.println ( " Yes the == returns true " ) ;
else
System.out.println ( " Yes the == returns false " ) ;

if ( b1.toString ( ).equals ( b1.toString ( ) ) ) // ( 2 )
System.out.println ( " Yes the == returns true " ) ;
else
System.out.println ( " Yes the == returns false " ) ;

}
}

---------------------------------------------------------------------------
at ( 1 ) , the addresses are compared which are different for b1.toString ( ) and b1.toString .

whereas at ( 2 ) the values that the strings have are compared which are equal

so , in a sense the values are the same but the addressses are different
others please shed some light on the issue

regards ,
Bhavesh




That is correct. if you want to compare the contents then use the equals() method, whereas the == operator checks if variables are referring to the same object. So in the example b1.toString() creates one String object and the second b1.toString() creates another String object. Therefore the variables are not refering to the same object. The below example demonstrate how to get two variables refering to the same object.

So if you wanted to check the contents of temp against temp2 then you would do the following:


Hope that helps.

Originally posted by jigar parekh:
I found one strange question,


Options :

a) true true true true true true
b) true false true false true false
c) true true false false false false
d) true false true true false false
e) true true false true false false
f) false false false false false false
g) compile-time error

Correct answer is : D

but according to me answer should be F bcoz string is imutable so it should return new instance of string object.

???



F is the correct answer, because the == operator is used to check whether two variables refer to the same object. In the instance of the example "String".trim(), "String".replace , etc all refer to different objects, therefore you'll get false. If you wanted to compare the contents of the String variable then use the equals() method. So "String".trim().equals("String".trim()) would give you true.


Thanks
you can also use strutstestcases. It is based on junit testing but designed for struts actions.
http://strutstestcase.sourceforge.net/
19 years ago
Hi there,

I have a form bean associated with a search page. This is an extract from the struts config file:

The user can perform a search in two different modes Advanced Search and Quick Search. For both search modes there are various categories on which search can be performed e.g. Quick Search - All, Quick Search - Images. Therefore i need to take the user back to the correct page from which the user has come from if a validation error occurs. Can anyone advise on this? What can i fill in in the input attribute for the action tag?


Thanks
19 years ago
Personally from my point of view I felt somewhat disappointed by the fight scenes in Batman Begins. But apart from that it's a totally awesome movie. It looks at every angle especially the conflict between Batman and Bruce Wayne.
19 years ago

Originally posted by Henrique Sousa:




Hi,
ok...I'm at the point of tearing my hair out! I've basically tried the following scenarios:

if session == null
if session.isRequestedSessionIdValid() !=true
if session.getAttribute("object") ==null

and i still get NullPointerException.

anymore advice will be much appreciated.

Thanks
19 years ago
JSP

Originally posted by Ben Souther:



The problem is that the my jsp page is a component inside another jsp page therefore i cannot use response.sendRedirect().

I have tried null == session.getAttribute("userBean")...but for some reason it still throws a NullPointerException.
19 years ago
JSP

Originally posted by Ben Souther:
Just check to see if the object stored in session is null.
If so, either redirect or forward to the login page.



I have been trying to implement this, but unfortunately I still get NullPointerException rather than session expiry page appearing.

Thanks
19 years ago
JSP
Hi,

I am currently working on a JSP search component which uses sessions. The default session timeout is set at 30mins. In my JSP page I implement the following:

This exception is caught in an error page which states:
"Session has Expired. Please start again".

The problem is when i test this page after 30mins I get a NullPointerException. After debugging I've found out that certain objects that I have placed in the session have disappeared. So I modified my code to do the following:



However, this does not solve the problem in that after 30mins I still get NullPointerException and not displaying "Session has expired". In the error page I catch IllegalStateException and print out the session expiry statement.

Can anyone tell me what other criteria I should look for when the session has expired?

Thanks
[ June 07, 2005: Message edited by: amz ]
19 years ago
JSP