This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSF context problem

 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi every body ,

I have a problem in backing bean .I want to take the context path in my backing bean .Let suppose I want to take one JSF files info like this way -> http://myTest/test.jsf.
I dont want to hard code it. I want all information from the JSF context .Is it possible ?


regards,
S
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In jsp file you can get contextpath using:
#{facesContext.externalContext.requestContextPath}

and in bean you can get context path using:
FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath()

Hope this helps.
 
S Majumder
Ranch Hand
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Smitha H Rao , for your reply .

I can get the FacesContext.getCurrentInstance().getExternalContext().getRequestContextPath() , it's fine , but at the same time I want remote address and the port number like this way :

http://127.0.0.1:8080/myApp/myJSF.jsf


regards,
S
 
Smitha H Rao
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can get remote address and port if you have HttpServletRequest object something like below:
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemoteAddr()
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemoteHost()
((HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest()).getRemotePort()
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic