Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting pageContext from request

 
Robert Willems
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Robert Willems
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you actually trying to do?
bear
 
Robert Willems
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic