Afzal Hossain

Greenhorn
+ Follow
since Jan 02, 2006
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 Afzal Hossain

Hi Neha,

I think you have to look up EJB from JNDI if you want to use it in Struts Action class. The Dependency Injection only works if the class is managed by the container. For instance , it is possible to use annotated dependency injection in Servlet, Listener, Tag Handler or any EJB. Therefore the struts Action instance is not managed by container so you can not directly use Annotated dependency.

And for the best practice you should use ServiceLocator design pattern for the JNDI lookup.

Thanks
Hi Friends,
When the PersistenceUnit is used it not only injects the EntityManagerFactory, it also registers a reference to it within the JNDI ENC of the EJB.

thanks
Hi Vijay,
First of all If persist() is called within transaction, the insert may happen immediately or it may be queued until the end of the transaction, depending on the flush mode. You can always force the insertion manually within a transaction by calling the flush( chapter 5 page 76 enterprise javabeans 3 o'reilly).

From your code: in public Request addRequest(..... ) method

Here you are calling sendToQueue(r.getId()); method while you are still in the transaction and the transaction will end after the addRequest(.... ) method returns. As because you are still in the transaction method the some entities might not be inserted immediately and the message driven bean will not able to find some entity. That is why you need to call manual flush method.


OR you could try by omitting the the line @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
from public Request addRequest(... ) method.

It seems redundant to use @TransactionAttribute in both methods addRequest(... ) and ddRequestUnit(....) . you should not use it in addRequest(.. ) method.

Your addRequestUnit(....) is fine and you are using @TransactionAttribute thats good.

Finally when we are dealing with concurrency i think it is a good idea to use flush method manually and we will be certain that the entity will persist.

These are all my understanding ... and sorry in advance if my guess is wrong..
Hope this info will help you
thanks
Hi Vijay Sekhri ,
I think it is NOT safe to assume that the request entity is persisted properly before the message is sent to the queue because entity manager will persist the entity when the request method is return. So i would suggest to use the flush method after persisting.

thanks
Congratulation.. score does not matter.
10 years ago
Hi friends,
Today i have passed SCWCD5 with 84% .
I have got 100% on Servlet Technology, Session Management, EL, Standard Action & J2EE patterns.
I got less score because i got only 50% on Structure & Deployment of web application section( it was hard)
I read HFSJ( 1st ), Hanumant Deshmukh book and did Enthuware mock (72% to 87%).
I have found one ambiguity question.

i have found 60% question from EL & customTags(with dynamic attribute), 6 questions from design pattern,6 questions from security, 5 questions from Filter, 9 questions from session & cookie, about 6 questions from Listener classes.
Hope this information will help you to do well in the exam.
Finally I would like to thank K&B and all of you guys. Good luck
10 years ago
You are most welcome friends.
10 years ago
JSP
HI there,
you can use the following EL to the jsp:

<c:if test="${param.search=='person'}">
<jsp:include page="page1.jsp"/>
</c:if>

because from the input form you are sending the information as a request paramater. So you can use param. Hope you understand.

Hope this will help you
thanks
10 years ago
JSP
Hi Varun Nayudu , If i specify scope as session in useBean action it is working. I think you have forgot to use HttpSession from servlet.
Hi there, Please make sure to implements Comparable or Comparator interface before trying to sort. Just letting you know in case you forget. Thanks
10 years ago
JSP
Hi there,
If you want to send information from html or jsp form to servlet in that case the data goes to servlet as request parameters and from request parameter you have to grab the data and instantiate the Person bean because there is no direct data binding. I have never seen any example of sending data as an attribute to servlet from JSP. I am still searching.. I think it is possible to do in some framework.
thanks
Afzal
Hi Aparna, the only Sun Certified Business Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-091) is available. SCBCD 1.3 is no more.Besides there is no Head first book for ejb3. Enterprise Javabean 3.0 from OREILLY and EJB3 in Action from manning are good books for preparation. Please visit http://www.sun.com/training/certification/java/scbcd.xml

thanks
10 years ago
Hi Deepak, As because you didn't use mapping, container creates 2 different instances of the generated servlet class one for accessing it as a named servlet and one for accesing it as a JSP page and will pass each servlet instance a different ServletConfig object. In order to be able to use the same instance and hence same configuration we have to explicitly map the JSP page's url as follows:
<servlet>
<servlet-name>HobbyFriends</servlet-name>
<jsp-file>/web/hobbyFriends.jsp</jsp-file>
<init-param>
<param-name>JSP_SERVLET_CONFIG_PARAM</param-name>
<param-value>JSP_SERVLET_CONFIG_VALUE</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>HobbyFriends</servlet-name>
<url-pattern>/web/hobbyFriends.jsp</url-pattern>
</servlet-mapping>

Now container will create only one instance of the generated servlet class and request for both the URLS will be served by the same instance, thus generating the same configuration.( i am quoting from Hanumant's book).

Hope this info will help you deepak.

Sorry sarat, it was for deepak.. And yes jspInit method is overriden.
Thanks
Hi sarat, I have run your code ... the problem is you did not use any mapping for the hobbyFriend.jsp file. It only works if you use any mapping instead of directly calling the jsp or servlet name. I hope you understand the point.
Thanks
Afzal