File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Getting pageContext from request Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting pageContext from request" Watch "Getting pageContext from request" New topic
Author

Getting pageContext from request

Robert Willems
Ranch Hand

Joined: Apr 14, 2003
Posts: 32
Hello everybody,
does anybody know how you where access the pageContext? I'm working on a project using Struts 1.1 and am searching for a way to access the pageContext from within a Action or a ActionForm. However all the stuff you get there are the ActionMapping, the Form, the Request and the Response. I'm stuck on finding the pageContext which i need to use the RequestUtils.message method.
Thanks in advance!
Regards,
Robert
Ps. Hope this doesn't belong in the Struts/Framework forum. If it does, my apologies.


Regards,<br />Robert Willems of Brilman<br /> <br />----------------------<br /> <br />SCJP 1.4<br />SCWCD 1.3<br />SCWCD 1.4 (beta)<br />SCDJWS 1.4 (beta)<br />SCBCD 1.3 (studying)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

There is no page context at that juncture. The page context only exists within a JSP page. Since your action has yet to forward to a JSP page, there's no page context.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Robert Willems
Ranch Hand

Joined: Apr 14, 2003
Posts: 32
Ah, ok... i was in the impression that a page had already been made somewhere... Now i can stop looking and think of something else ;-)
Thanks!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61769
    
  67

What are you actually trying to do?
bear
Robert Willems
Ranch Hand

Joined: Apr 14, 2003
Posts: 32
I needed to get a message from the default message bundle within a Action.execute() and a ActionForm.validate();
I stored the localized format string to use in the bundle.
However as i'm quite lazy (sometimes a good thing for a programmer ;-)) i wanted to use thre RequestUtils.message() method to get the message for me. However that method needs the pageContext.
Now i just have to use the Globals.MESSAGES_KEY to get the bundle out of my ServletContext...
Regards,
Robert
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting pageContext from request