Redirect to another page from a session bean

This solution doesn't work because It's called from the session bean I think.

I got this error:

non-static method getExternalContext() cannot be referenced from a static context
LVL 1
NargzulAsked:
Who is Participating?
 
jwentingConnect With a Mentor Commented:
you can't do that from an EJB, EJBs know nothing of HTTP traffic.
What you can do is return an indication of what needs to be redirected to to the controller servlet and have that do the redirect.

But yes, you're calling an instance method from a static method (and you almost never want to use static methods, especially in EJB and other implicitly or explicitly multi-threaded context). It's the only way you can ever get the error you're posting. That the method you're calling isn't going to help you do what you want to do is secondary to that.
0
 
objectsCommented:
that suggests that you are calling it from a static method in your bean, needs to be called from a non-static method
0
 
NargzulAuthor Commented:
But the method isn't static, it's why I don't really understand.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
objectsCommented:
can you post the relevant code
0
 
NargzulAuthor Commented:
I don't really understand one thing:
For me an EJB is a bean, stateless or statefull, we can map, remote or local.

But, this one isn't mapped or anything like this, just a session beans.

I'm sorry, I don't have more the code because I've found a solution that doesn't need to do a redirection from a sessionbean.

So this "question" isn't really more usefull, but I'm absolutly sure that the method wasn't static, it's the first thing I've check when I've seen this error.
0
 
NargzulAuthor Commented:
I've created a jsp:forward code that goes look into the session bean to be rendered
0
All Courses

From novice to tech pro — start learning today.