JSP and threading


Web tier: servlets, JSP, Web frameworks: JSP and threading

  1. JSP and threading (4 messages)

    When I tried to use a Bean within my JSP, it always fails with a threading exception. The bean is a multithreaded program. Can JSP use beans which are multi-threaded? Any suggestion will be appreciated.

    Threaded Messages (4)

  2. JSP and threading[ Go to top ]

    I noticed the JSP 1.1 spec says JSPs have the same threading issues and restrictions referenced in the Servlet spec.
    Note this relevant item from the Servlet 2.2 spec:
    "A Servlet Container may place security restrictions on the environment that a servlet executes in. In
    a Java 2 Platform Standard Edition 1.2 (J2SE) or Java 2 Platform Enterprise Edition 1.2 (J2EE)
    environment, these restrictions should be placed using the permission architecture defined by Java 2
    Platform. For example, high end application servers may limit certain action, such as the creation of
    a Thread object, to insure that other components of the container are not negatively impacted."

    I know you can create your own threads under WebLogic,
    but I've seen BEA technical support people posting and saying that although it works... it is unsupported.

    What JSP container are you using, and what is the exception stack trace?
  3. JSP and threading[ Go to top ]


    I am using sun's J2EE reference implementation right now, but it will eventually be moved to iPlanet/JRun. You are absolutely right, it seems to work in WebLogic when I tried a small test app with the multithreaded bean. However it fails in the J2EE server..I am not at work today but I will let you know about the stack trace as soon as possible. But does the Servlet spec say anything about prohibiting threads within user components? I am not using an App server just the JSP engine.
  4. JSP and threading[ Go to top ]

    I just made a simple JSP and JavaBean,
    and installed them under the J2EE reference edition.

    The JavaBean did create a new Thread object and begin it's
    run() method.

    I was able to use the useBean tag in the JSP to instantiate
    the JavaBean, and the JavaBean did create and begin running a new thread.

    So I would say there is nothing in the reference edition
    which specifically prevents this, although I did find
    a warning in 1.2 of the j2ee spec (the warning is about
    the JavaMail API, but note the caution against creating threads):

    "Note that the JavaMail API creates threads to deliver notifications of Store, Folder, and Transport events.
    The use of these notification facilities may be limited by the restrictions on the use of threads
    in various containers. In EJB containers, for instance, it is typically not possible to create threads."

    So we've both seen it work in WebLogic, and it works for
    me in the j2ee reference server from Sun. Of course,
    my example is totally trivial... it depends on what your
    "multithread bean" is doing.

    Did your stack trace complain about "can't instanitate bean of class xxxx?" If so, I did have that problem until my classpaths were sorted out.

    So post your stack trace and I'll happily look. No promises! :)

  5. JSP and threading[ Go to top ]

    Thanks Marc, I got it to work. It was a class path issue.