Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!

Tony Tung

Greenhorn
+ Follow
since Aug 07, 2009
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 Tony Tung

Tony Tung wrote:I double DI like @EJB can be used in client side .

Maybe you could use JNDI - lookup method to invoke session bean class .



I correct my word , @EJB can use in client side .

but should annotate like @EJB GreetUserLocal guser

and invoke bean class method guser.sayHallo()
I double DI like @EJB can be used in client side .

Maybe you could use JNDI - lookup method to invoke session bean class .

Vignesh Murali Natarajan wrote:

Tony Tung wrote: I got the Answer is D , but I think it may be wrong because Application Exception must have Rollback = True
to get automatic rollback if it is not rumetimeexception or any uncheck exception .



Hi,
Option D is the right answer in my opinion because the problem statement clearly states that the client should be able to use the same transaction to correct the problem



Dear Natarajan

Refenece Enterprise JavaBean 3.0 , Application Exceoption set Rollback by default (=faulse) mean it would not
automatically to rollback , but give oppertunity to recorrect data in the client . because no action excuting before
exception is throw , so nothing to need rollback .

I think D option is right to this situation .
sorry , javax.ejb.EJBTransactionRequiredException exist .

But EJBException is subclass from RuntimeException , if you custom application exception into RuntimeException
, Maybe D option could be right answer .
A developer is working on a user registration application using EJB 3.0.
A business method registerUser in stateless session bean RegistrationBean performs the user registration.
The registerUser method executes in a transaction context started by the client.
If some invalid user data causes the registration to fail,
the client invokes registerUser again with corrected data using the same transaction.
Which design can meet this requirement?

A. Have registerUser method call EJBContext.setRollbackOnly() method after registration fails

B. Have registerUser method throw javax.ejb.EJBTransactionRequiredException after registration fails

C. Have registerUser method throw EJBException without marking the transaction for rollback, after registration fails

D. Create an application exception with the rollback attribute set to false and have registerUser method throw it after registration fails


I got the Answer is D , but I think it may be wrong because Application Exception must have Rollback = True
to get automatic rollback if it is not rumetimeexception or any uncheck exception .

A option is wrong , reason is below list
The setRollbackOnly and getRollbackOnly methods can only be
invoked in an EJB using CMT with these transaction attributes: REQUIRED,
REQUIRES_NEW, or MANDATORY. Otherwise, the container will throw an
IllegalStateException.

B option javax.ejb.EJBTransactionRequiredException seem not to exist

C option is only one could be right answer .

Will someone could answer this question ? thanks a lot
sorry , I am too lazy to test code .

B option wrong point at

<% product.setPrice( request.getParameter( "price" ) ); %>

it should be <% product.setPrice( Double.ParseDouble(request.getParameter( "price" )) ); %>
Assume the product attribute does NOT yet exist in any scope.
Which two create an instance of com.example.Product and initialize the name and price
properties to the name and price request parameters? (Choose two.)

A. <jsp:useBean id="product" class="com.example.Product" />
<jsp:setProperty name="product" property="*" />

B. <jsp:useBean id="product" class="com.example.Product" />
<% product.setName( request.getParameter( "name" ) ); %>
<% product.setPrice( request.getParameter( "price" ) ); %>

C. <jsp:useBean id="product" class="com.example.Product" />
<jsp:setProperty name="product" property="name"
value="${param.name}" />
<jsp:setProperty name="product" property="price"
value="${param.price}" />

D. <jsp:useBean id="product" class="com.example.Product">
<jsp:setProperty name="product" property="name"
value="${name}" />
<jsp:setProperty name="product" property="price"
value="${price}" />
</jsp:useBean>

Answer: A, C

why B option is wrong ?

I can not see any question in option B .

Someone can tell what wrong with it , thanks a lot .
you can use ServletContext.getSession().getAttribute('myAttribute') to retrieve any attribute in session
Which two statements are true about using the isUserinRole method to implement security in a Java EE application? (Choose two.)
A. It can be invoked only from the doGet or doPost methods.
B. It can be used independently of the getRemoteUser method.
C. Can return “true” even when its argument is NOT defined as a valid role name in the deployment descriptor.
D. Using the isUserlnRole method overrides any declarative authentication related to the method in which it is invoked.
E. Using the isUserlnRole method overrides any declarative authorization related to the method in which it is invoked.


=========================================================================
B option is true , C option seem to be wrong but someone say it is true

E option should be true

anyone can tell me reason if C option is true ?

thank a lot
hello , I supose that Jsp implict variable not include servlet parameter part .

is right ?