Using Applets

nick5454
nick5454 used Ask the Experts™
on
In the J2EE architecture it says to use applets for designated areas within the JSP page to access business components. My instructor says to use the servlet instead. That contradicts the J2EE specifications. WHich is the best.

Applets take a while the first time. But what is the correct practice.

Thanks,
Nick
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
I am not sure what the J2EE spec explicitly says but in my experience, we have always used Servlets to access Business Components/Objects.  Following the MVC design.

CJ
Mick BarryJava Developer
Top Expert 2010

Commented:
Applets don't really have access to your business components in J2EE. Applets run on the client, while your business components run on the server.
Can you point to a reference making this recomendation to use applets and we can try to explain what they mean.

Author

Commented:
Well its in the Simplified J2EE specs. But, I am going to use the applets for animation and I guess thats the real purpose for banners and things like that.

My last question then is do I create a class that inherits the servlett class that calls and EJB?

And are java beans on a jsp page common practice or do I stay away?
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

Commented:
have your class (otherwise known as a servlet) extend HttpServlet.

Here is a skeleton structure:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class SomeServlet extends HttpServlet {
  public void doGet(HttpServletRequest request,
                    HttpServletResponse response)
      throws ServletException, IOException {
     
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    doGet(request, response);
  }

You can use a Java Bean - a value class or data object in your JSP for display.

CJ
}

Mick BarryJava Developer
Top Expert 2010

Commented:
JavaBeans are most useful in a jsp page, as their are tags designed to access them.
They don't have any real advantage over other classes in a servlet.

Author

Commented:
Thanks for the code I really appreciate both of your answers

nick

Commented:
Thank you for the "A" and good luck.

CJ

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial