Hello,

Was there anyone that was able to solve this issue.

I have pretty much what Ruben has.  But when clicking the delete link, I am
unable to get the DeletePersonServlet.java to work without errors.

When I am trying the code, I keep getting one of the following errors:
java.lang.NullPointerException
or
javax.servlet.ServletException: java.lang.IllegalArgumentException: Object:
123 is not a known entity type.

Here's what I have for the code in the DeletePersonServlet.java.  Maybe
it's missing something or a piece of it is not correct.


public class DeletePersonServlet extends HttpServlet {
    @PersistenceUnit
    //The emf corresponding to
    private EntityManagerFactory emf;

    @Resource
    private UserTransaction utx;

    protected void processRequest(HttpServletRequest request,
HttpServletResponse response)
    throws ServletException, IOException {
        assert emf != null;  //Make sure injection went through correctly.
        EntityManager em = null;
        try {
            String id = (String) request.getParameter("id");

          //System.out.println("ID is: " + id);

            //begin a transaction
            utx.begin();
            //create an em.
            em = emf.createEntityManager();

          em.merge(id);
            em.remove(id);

            //commit transaction
            utx.commit();
      } catch (Exception ex) {
            throw new ServletException(ex);
        } finally {
            em.close();
        }
    }
}


Hopefully someone can point me in the right direction.

Beverly



                                                                           
             Rudi                                                          
             <[EMAIL PROTECTED]                                             
             ahoo.com>                                                  To 
             Sent by:                  "Java EE (J2EE) Programming with    
             java-ee-j2ee-prog         Passion!"                           
             ramming-with-pass         <java-ee-j2ee-programming-with-pass 
             [EMAIL PROTECTED]         [EMAIL PROTECTED]>               
             com                                                        cc 
                                                                           
                                                                   Subject 
             10/12/2008 02:08          [java ee programming] JPA Basics    
             AM                        Homework 16                         
                                                                           
                                                                           
             Please respond to                                             
             [EMAIL PROTECTED]                                             
                  hoo.com                                                  
                                                                           
                                                                           





Hi Everyone,

  I wrote the DeletePersonServlet.java. Then I added a link to the
ListPerson.jsp
for the Delete option.

  However, I'm confused as to how to tie things together in order to
make the delete link work.

  How do I get the Delete link to call my servlet?

  I imagine that we leave the rest of the code in MyWebJPA the way it
is and that we don't need to change the ListPerson.jsp to use JSF tags
like <h:outputText or anything.

  Thanks in advance.

Best regards.

Ruben







--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Java 
EE (J2EE) Programming with Passion!" group.
To post to this group, send email to 
java-ee-j2ee-programming-with-passion@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/java-ee-j2ee-programming-with-passion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to