Link to home
Start Free TrialLog in
Avatar of Nargzul
Nargzul

asked on

retrieve GET parameter in a request bean

Hi!

I have a page accessed by a link into an email.

How can I retrieve a GET parameter from my Request Bean?

Thank you!
(I use JSF/JSP under a glassfish server with netbeans)
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Why not store it in the request map and have your bean access that?
Avatar of Nargzul
Nargzul

ASKER

I'm sorry, I don't understand what you mean.

request map == face-config?

The url in the email will be something lik

http://myWebSite.com/MyPage.jsf?idDeal=3517&authKey=341AFE80CFB419750D

I want to have a direct access to this page.
>>request map == face-config?

request.setAttribute("x", y);

Avatar of Nargzul

ASKER

>>request.setAttribute("x", y);
How do we get this object?

Email are in a mail, I don't think it works and they aren't sent from the same server(and it's not a J2EE server).
Avatar of Nargzul

ASKER

You don't really help here...

When must I use this?
What do I write in the email?
Is this really done for JSP/JSF?(because I see always "servlet" in the javadoc)
How do I get this ExternalContext?

Why is it so complicated???
It's just amazing, I only want to retrieve a Get variable. In php it's only a $_GET['my_var_name'], in .NET it's only a Request.QueryString("parameter1")
The difference is you're using multi-layered technologies. PHP is shallow in comparision. Exactly what layer of your app are you in? If you have access to the request object, then of course it's equally easy
Avatar of Nargzul

ASKER

Theses layer must simplify the development no?

I'm in a Bean with a Request scope, in a getter of one attribut of my bean.

>>Theses layer must simplify the development no?

No, that's not the objective. They actually make it more complex. The objective is to increase reusability and scalability

A bean is not meant to have circular references to the request, hence your problem. You would be better to rethink the design, but a kludge would be to pass the request into the bean

Avatar of Nargzul

ASKER

But say me how I can do it differently?

I need to have:
-a link from an email
-can load an object corresponding to the given ID in my RequestBean
So the user clicks on a link in an email?

>>can load an object corresponding to the given ID in my RequestBean

What object?
Avatar of Nargzul

ASKER

It's an Entity object, I've a facade(session bean) to load it
    @EJB
    private MatchFacadeRemote matchfac;
 
    public Match getMatchToReview() {
        if(matchToReview == null){
            int idMatch = xxxxxx;//here we get this object
            matchToReview = matchfac.find(idMatch);
        }
        return matchToReview;
    }

Open in new window

What is the first thing that gets hit when the user clicks on the link in the email? Do you have jsp, servlet or what?
Avatar of Nargzul

ASKER

It's a JSP page
Avatar of Nargzul

ASKER

Yeah it's an email, it was specified in the first message ;)
In that case it would be e.g.
String authKey = request.getParameter("authKey");

Open in new window

Avatar of Nargzul

ASKER

I've try but I don't have this request var
That's *always* present in a jsp
Avatar of Nargzul

ASKER

I'm confuse, I've responded to fast to your question, I've only JSF pages
Avatar of Nargzul

ASKER

I've tried to create an ExternalContext, but it's an abstract class.

I've created a FaceContext, but there isn't any getRequestMap on this method.

I've check there isn't any :

get***Map() on the ExternalContext
You need to read the link i posted to you - it tells you exactly what to do
Avatar of Nargzul

ASKER

Okay,

So I've try to do mixes, but when I call the page like this:
http://localhost:8080/TrustBN-war/faces/ReviewExchange.jsp?idReview=120938120839

I get a null in my code
FacesContext context = FacesContext.getCurrentInstance();
String idReview = (String)context.getExternalContext().getRequestMap().get("idReview");
System.out.println(idReview);

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Nargzul

ASKER

Yeah it works

Thank you sooo much!
:-)