Solved

Redirect to another page from a session bean

Posted on 2009-07-02
6
762 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 55
listing all functions in JavaScript 19 177
Java - Why doesn't this JFrame work 3 41
Way to decrease size of apk file 9 42
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

911 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now