anagha desai

+ Follow
since May 08, 2008
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
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by anagha desai

Hello ,
A simple web app to test BASIC auth method .
Here is my code from web .xml ::

Had a couple of questions

1 >when I try and access one of the jsps using a url - I get a login screen
I enter proper credentials and I am taken to desired page

On this page - have a link to the next page

When I click on the link I am successfully going to next page .

Since Http is stateless and both resources are protected - why is the second request not being asked the login credentials again
( I agree this is the nice / correct thing to happen - but how is the state being maintained ? )

2 >
If I remove the following from web.xml ::

Now if I try and access the page - I get through fine withou any authentication

Question ::
My understanding was - with this change app should still ask for authentication but no authorization reqd

Evidently my understanding is incorrect .

9 years ago
I am trying to do a simple login where I want to do the following ::
1 >App consists of Login.jsp , A.jsp & B.jsp

2 >If user is not logged in user should always be directed to Login.jsp

3 >User should not be able to access any JSP directly

My queries / doubts and tries from my end ::

I tried to make use of a managed bean with session scope in "faces-config.xml "

Question :: Against what attribute is it stored in the session ?
If I want to access the bean stored in HttpSession what should be the parameter against which I need to lookup ?

Is the bean available to a Non JSF component ? ( servlet - it should be since session is available ?)

Regarding preventing direct access to JSP
I dont want to use container provided security .
So please please lets not go that route
( This is too simple a use case to warrant container security )
I want to simply everytime check the HttpSession if the user bean exists on session or not !
If it does - allow user to access the jsp
If not - simply throw the user out to login screen

Will I have to use a PhaseListener ? ( clueless regarding how to use it and why to use it !
will I have to use a filter ?

I really dont know and I am a little mad at is - that this is fairly a simple thing to do and were this struts / servlets this would be done in a jiffy

with jsf this is becoming a difficult task to just simply store / retrieve data in request / session

maybe I am new / havent read enough hence the frustration - but I am beginning to wonder why jsf ?

9 years ago
Reading "EJB3 in action " about application managed entity managers

My understanding was that such entity managers can ONLY JOIN an existing Tx

Here is an excerpt from book ::

As we hinted in the beginning of this section, unlike container-managed
EntityManagers, application-managed EntityManagers do not automatically participate
in an enclosing transaction. Instead, they must be asked to join an
enclosing JTA transaction by calling the joinTransaction method

However in Chapter 12 - the book also shows an example where an application managed entity manager in a Java EE5 container is starting and committing a transaction .

Is this an error or are App managed Entity managers allowed to both Join and initiate JTA Transactions ?

Hello ,
Tried googling and looking at various posts in Javaranch for the differnece between getting a RequestDispatcher from servletContext and from request .

What I understand is ::
Request :: The path can be "relative" or the path can be "literal"

ServletContext :: The Path must be literal

If in Tomcat I have the following structure ::

( JSP location )
<<TOMCAT_HOME>> / webapps / myApp / view/display.jsp

( Actual servlet location )
<<TOMCAT_HOME>> / webapps / classes / com / ex / serv1.class

In my servlet I tried both of these and it worked .

So I am still not quite sure where there would be a need to use a specific Request dispatcher ?

[ August 01, 2008: Message edited by: anagha desai ]
9 years ago
Not sure if this helps but here is what I did ::

was using JPA so needed to configure it in " persistence.xml"

Then I wrote a JSP client to use this Datasource :: ( pasting relevant portion )

Thanks to Jaikiran helping me out earlier for my queries .

I hope this is what you are looking / referring to ?

Thanks ,
9 years ago
Hello ,
Am trying to explore SEAM and after looking at the first example my views are ::

Using EL we bind the data to a backed up bean
( advantage being no need to manually set values )

Backed up bean needs to have wo annotations
@Name & @Scope

Action Listener is bound to the UI using a annotation of @In

After looking at all of this * am used to developing apps using struts )

I find struts much cleaner and much more layered

Seam in an attempt to avoid XML seems to have annotations freely thrown around

My understanding is SEEMS totally violates MVC - here the View is configured with Model

I am new and maybe I do not understand the details - but to my novice eye
is SEAM really worth it ?

Also is it app server independent or is it something specific to Jboss ?

People complain about the struts-config file being monolithic - but my arguement is atleast you have all config elements at one place !

Final question - and this frustrates me the most ( maybe I should leave software ! ) - why is there a need to change what works well in struts with the introduction of JSF / SEAM

Am expecting to be smacked over my head - but I need to vent my frustrations !

9 years ago
Wanted to know if the above method is no longer required in EJB 3 ?

I am guessing that since we no longer have a Home INterface ( Version 3.x ) so above method is no longer required .

1 >Why is the Home interface no longer required in version 3.x ?

Thanks ,
Thanks Ilja and Steve for the responses .

So from the framework perspective - would Action classes be an example of command pattern ( not simply because they contain a "execute" method !)

Here we extend and define our own action classes as we desire and then make calls to the model / business logic ( similar to the Receiver in command pattern )

So struts action classes could be thought of as command objects ?

Thanks ,
Was reading Head First design patterns for above pattern .

(From the xample given in the book )

I have either not understood / or feel that there seem to be a couple of issues with this pattern ::

1 >
looks like there will be a number of Command Objects to be created for the same receiver if the receiver is to perform a no of actions :

Ex : Lets say there is a Receiver called :: "Gadget"
It can perform the following operations ::
" on "
" off "
" run "
" bark "

Now for such a receiver if I were to use this pattern - then I would have 4 Command Objects to encapsulate / wrap the four calls ?

Wouldnt this be too much of classes ?

2 >
The receiver is wrapped in the command
The command is wrapped in the invoker
Client calls the execute method of command embedded in invoker

The client needs to upfront know the command that needs to be used
Client needs to know the type of Receiver and needs to set it to the command

What I dont understand / find very nice is - the client needs to do a lot of things himself .

Why dont I just call the method of the receiver rather than juggle around with so many settings of one object into the other ?

I am sure that I will get responses - but please do help me in grasping this concept .

The problem at my end seems to be - I do try and read but unless the concept is understood - it tends to fade over time

This is the third / fourth time that I am reading this and other patterns !

Thank you all for your inputs .
My question was not regarding clearing a collection for reuse but was related to GC.

Thank you all for your thoughts.

9 years ago
Hello ,
If I declare a List (collection object ) in a method ( local variable ) and then I populate it with a couple of other objects .

Do some business logic and then return a boolean value .

Essentially the Collection is not returned .

In such a case ( since the collection is populated with other objects )
would it be a good idea to explicitly clear the collection of the other objects

( My understanding is that thios will not be necessary since the collection is getting deferenced after scope of method is completed )

However would the garbage collector perform more efficciently if I were to clear the collection or would it make no difference ?

9 years ago
Hello ,
I am new to EJB ( only worked for brief time on 1.1 Version )

One of the advantages being touted is use of "annotations" as compared to Deployment descriptor .

In the book "Mastering EJB " - it is stated that XML is prone to errors due to human editing .

1 >
I really find that difficult to digest
Dont we use "web.xml" in servlet apps - dont see issues there ?
struts-config.xml in struts is also xml driven ?

Or are we going to say that these are also problematic ?

2 >
One takeaway from EJB DD was supposedly the point of changing behaviour without changing code ( by changing DD )
With annotation that is lost right ?
So is that an advantage or a disadvantage ?

3 >
Not sure but think have read that DD will override annotations if both are present ?

so does this mean that in dev env - use annotations and in prod use deployment descriptor ?
( if thats true - i would prefer sticking with DD )

Thoughts ideas and criticism are welcome

[ June 09, 2008: Message edited by: anagha desai ]
Thanks JOanne and Ritchie
This does help and clarify the doubt .

Its really nice on both of you to help out .

Thanks ,

[ June 06, 2008: Message edited by: anagha desai ]
[ June 06, 2008: Message edited by: anagha desai ]
9 years ago
Hello ,
Here is an Ex :

Confused regarding why and how the compiler allows this - I know that all classes extend from Object class - but the interface doesnt right ?

So what gives .... ?

Thanks ,
9 years ago
New to JSF

Have some amount of experience in Struts
So inevitably I am comparing the two .

So one thing I dont understand is ::
In struts we have action classes through which we start talking to the model

In JSF looks like the UI is bound to the bean ( to populate data from UI )
( Similar to the ActionForm from struts ? )

However where is the clean handoff to model in JSF ( the way struts hands off control from action class ? )

9 years ago