Solved

Redirect to another page from a session bean

Posted on 2009-07-02
6
767 Views
Last Modified: 2013-11-24
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
Comment
Question by:Nargzul
  • 3
  • 2
6 Comments
 
LVL 92

Expert Comment

by:objects
ID: 24769046
that suggests that you are calling it from a static method in your bean, needs to be called from a non-static method
0
 
LVL 1

Author Comment

by:Nargzul
ID: 24769111
But the method isn't static, it's why I don't really understand.
0
 
LVL 92

Expert Comment

by:objects
ID: 24769128
can you post the relevant code
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 6

Accepted Solution

by:
jwenting earned 500 total points
ID: 24769760
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
 
LVL 1

Author Comment

by:Nargzul
ID: 24784446
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
 
LVL 1

Author Comment

by:Nargzul
ID: 24845105
I've created a jsp:forward code that goes look into the session bean to be rendered
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question