Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 798
  • Last Modified:

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
0
Nargzul
Asked:
Nargzul
  • 3
  • 2
1 Solution
 
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
 
objectsCommented:
can you post the relevant code
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jwentingCommented:
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
 
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

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now