How-to get the JSF application context path?

I want to do a redirect from within a JSF backing bean. How do I get the application context path?
I plan to do this in the constructor of the backing beans in order to validate the user has previously logged in.
public BackingBeanName()
FacesContext facesContext = FacesContext.getCurrentInstance();
HttpSession session = HttpSession)facesContext.getExternalContext().getSession(false);
HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
userid = (String)session.getAttribute("userid");
if (userid == null) {
logger.info("userid attribute is not in session");
ExternalContext ec = facesContext.getExternalContext();
appContextPath = ???????????????????????;
String redirectTo = appContextPath + "/logon.jsp";
try {
ec.redirect(redirectTo);
catch (IOException e) {
String msg = "redirect to " + redirectTo + " failed";
logger.severe(msg);
return; // throw an exception instead of return;
Regards,
Al Malin

Frank, your suggestion of using JSF global navigation to the logon page looks like what I need but I need some advice implementing it.
My backing bean constructor looks like this:
public Search()
FacesContext facesContext = FacesContext.getCurrentInstance();
String userid = GpaUtil.getSessionUserid(facesContext);
if (userid == null)
logger.info("session userid not found, going to logon page");
??????? What goes here ????????
??????? I think I need to fire an event but I'm not sure how to do it, ????????
??????? let alone if this is what needs to be done ????????
??????? or even if this is the right spot in the code ????????
gpas = ProductApproval.retrieveList("1=1","1");
FWIW, the navigation rule looks like this:
<navigation-rule>
<navigation-case>
<from-outcome>goLogon</from-outcome>
<to-view-id>/logon.jsp</to-view-id>
</navigation-case>
</navigation-rule>
Your help is greatly appreciated.
Regards,
Al Malin

Similar Messages

  • How to get the active application users IP address in R12 by sql command

    Hi ,
    I need to know how to get the active application users IP in R12 by sql command
    in order to kill any session by the IP address ?
    Am working on 12.1.3 Application
    And 11.2.0.3 Oracle Database
    Thanks

    936921 wrote:
    Am still couldn't found the IP address for the connected Application users.
    If there any select statement can help me with that?
    Really? Then how do you explain me finding the following docs from the links I referenced above?
    How To Find The IP Address Of The Client Machine From Where A Particular Forms User Is Connected ? (Doc ID 879092.1)
    How to Track IP Address of the Form Session in Oracle application 11i (Doc ID 878931.1)
    Where to find the Client IP Address for a Client in E-Business Suite? (Doc ID 1258415.1)
    How To Get The terminal ID For The Machine From Which A User Is Logged To E-Business Suite Applications (Doc ID 751658.1)
    Thanks,
    Hussein

  • How to get the SharePoint user context available in custom federated search connector?

    Hi,
    I'm investigating the possibilities for developing a federated search connector for SharePoint 2013 Online. This should allow us to search a customer's database through our custom developed application (both on premise). We intend to develop
    an remote federated search connector (using OpenSearch protocol) and configure a result source in SharePoint for that connector.
    The problem I'm struggling with is that I want different search results from this ressult source based on the permissions of the user that is executing the search. The admin should find a lot because he has permissions on certain items in the custom
    application. The employee should find just a few because he has no permissions on certain items in the custom application. We developed the custom application ourselveds and the search in that application is taking permissions into account: it doesn't
    return results if a user doesn't have sufficient permissions. That part works just fine.
    However, to be able to use that, the remote federated search connector must be able to identify the user that is executing the search in SharePoint Online. So: how do I get the SharePoint user context in the remote federated search connector?
    I know I can configure the replacement token {User.Name} in the result source configuration, but that gives me the name of the user only. This is insufficient to get an identity, principal, token or whatever, that let's me log in into our custom
    application.
    I also know that in a provider hosted app, user context is passed through from SharePoint and is known within the remote app. But since result sources need fixed (or anonymous) credentials configuration for connecting to the remote federated search connector,
    all users will be using the same credentials. This makes me assume these credentials are for securing communication and cannot be used within the execution of the search within the remote federated search connector.
    At the moment, I'm stuck. Any help will be greatly appreciated.
    Cheers,
    Ruud.

    Hi,
    Per my knowledge, we cannot get the SharePoint user context available in custom federated search connector with other methods.
    Here is a similar thread for your reference:
    https://answers.atlassian.com/questions/263735/atlassian-sharepoint-connector-federated-search-authentication-and-authorization
    Thanks,
    Linda Li                
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Linda Li
    TechNet Community Support

  • How to get the current application root directory

    Hi Experts,
    I am deploying an ADF Application to a Standalone WLS 10.3. During development I am using Integrated WLS (which comes with JDeveloper 11.1.1.5.0). During development, I configured my application to create log files in my local machine (where Integrated WLS is running) by using absolute path for my log file. Now, I am moving to a standalone instance of WLS for testing (before moving to production).
    Now I need to keep my log files under my application root directory. Please let me know how to get the absolute path of the deployed application root directory from WLS ENV/System property into my application's Java Code.
    I tried the below java code,
    Current weblogic server name is: " + System.getProperty("weblogic.Name") --> This gives me the name of the server where my application is running.
    Current weblogic server name is: " + System.getProperty("weblogic.Root") --> This returns NULL. How to get the Root directory of my application using some system property inside my application at runtime??
    Thanks
    Rathnam

    One method is to create a File(""); and do getPath() on it.
    At least it's worked for me.

  • How to get the local file system path of an image that loaded into the image component in cq5?

    Hi,
    I'm having hard time uploading image from filesystem where as drag and drop works.
    I'm not getting a path of image selected from filesystem.
    here is my code..
    private String populateImage() throws Exception {
                        if (currentNode != null && currentNode.isNode()) {
                                       Node ImageNode = JcrResourceUtil.createPath(currentNode, "image",
                                                                          null, "nt:unstructured", true);
                                       imageUrl = ImageNode.hasProperty("fileReference") ? ImageNode.getProperty("fileReference").getValue().getString() : "";
           imageUrl = imageUrl.trim();
            log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE IF IS: " + imageUrl);
                        } else {
                                            imageUrl = properties.get("fileReference", "");
                                            imageUrl = imageUrl.trim();
                                            log.info("MANAGE PROFILE BEAN IMAGE URL INSIDE ELSE IS: " + imageUrl);
                        return imageUrl;
    So if I drag and drop..
    ImageNode.hasProperty("fileReference") is returning a valid path
    but if I upload an image  it is returning Null.
    So how to get the path? any suggestions around would be appreciated...

    When you say path you mean you want the path to print out in your HTML? Is that accurate? If so you generally need to constructe that path based on the path to the current component. So if you component is located at /content/mysite/en/about/mypage/jcr:content/parsys/image then the path to the image would generally be something like /content/mysite/en/about/mypage/jcr:content/parsys/image.img.jpg/1283829292873.jpg. The .img. selector triggers the servlet associated with the foundation parbase - /libs/foundation/components/parbase/img.GET.java. The reason you reference it this way is that there is no filesystem path to the image - it is stored in the repository not on the file system, and it requires a servlet or script to ge the binary from the repository and steam it.
    Normally the way you'd construct this is to use the out of the box Image class - so look at /libs/foundation/components/image/image.jsp. Now this example assumes that your component where you loaded the image extends /libs/foundation/components/parbase. If it doesn't then you either have to change your sling:superResourceType to /libs/foundation/components/parbase or some other component that does exten /libs/foundation/components/parbase.

  • NSImageView - How to get the image file's path?

    I'm working on an image uploader application, and am having difficulties getting the info I want from an editable NSImageView. Basically I have an NSImageView object which the user can drag an image file to display a preview and add to the list of images to be uploaded. The image is loaded into the NSImageView just fine, however for my purposes I need access to the actual file path of the image.
    The NSImageView target function is activated when an image file is dragged onto the view, however at that point an NSImage is provided and I have yet to figure out how to get access to the file name. Anyone have any suggestions regarding this?

    This may be helpful.
    http://nsnotfound.blogspot.com/2007/08/nsimageview-and-image-filenames.html
    Eric

  • How to get the name, version and path of the oracle suite(s) installed

    Hi,
    I am trying to gather information regarding the Name, Version and Path of Oracle installation(s) on a computer.
    E.g.
    Name = Oracle Database 9i Enterprise Edition
    Version = 9.0.00
    Path = C:\Oracle
    I don't want to do it by querying the system tables. Can anyone please guide me if there is anyway to get these from either registry, WMI or API.
    Any form of help is highly appreciated.
    Thanks in advance.

    Simply invoke installer (OUI).
    Werner

  • How to get the web application root ?

    Hi,
    We are developing a JSP/Servlets web application for Weblogic 5.1, that is distributed as a WAR archive, and so far we are unable to determine the web application root dynamically (from within the code in a Servlet or class). We tryed the servletContext.getRealPath("/") method, but it is not working due to the fact that we are deploying the application as a WAR file.
    We need to have this app root at the application startup, because it is widely used inside the JSP pages and the servlets of the web application. Also we would like to avoid setting it as a static parameter in the web.xml or elsewhere.
    Does anyone know how to do that? Any hint or suggestion is very much appreciated!
    TIA
    Stefan Buynov

    Thanks for your reply.
    As I said in one of my early posts, this variable (the application root) i used widely in the application (not only in JSPs, but also in classes).
    Another problem will be including JSTL in the project - first of all, I will have to put this tag where the variable is required (it will be quite exhausting), and also the specification of the application is strict - I might not be able to add this tag library, since the client won't like it.
    Anyway, thanks for your concern.
    Regards,
    Stefan

  • How to get the ownership application

    Hi,
    I am trying to create the ownership applicatoion,
    I have gone to add a new application named it as "ownership" and mentioned the dimension type as Ownership . But in the lat step the system throws an error
    "Required dimension type is missing  I "
    Please help me resolve the issue.
    Thanks
    Navin

    Hi Navin,
    I suggest to follow one of SAP BPC trainings. This will help you to understand the product and it will keep you away by this kind of issues.
    To answer to your question...
    1. You have to create first the dimensions for an application and after that you can create your application selecting the dimensions what you need for that applications.
    Even if you start from RAte application after that you are able to add or to delete dimensions from that application.
    Kind Regards
    Sorin Radulescu

  • How to get the full path or name of the Layer to which Filter is applied?

    Hi All,
              I have created a layer using some background image as source. How to get the name or ful path of the background image?
    I checked the documentation and found GetPathNameProc(SPPlatformFileSpecification*) function, but I couldn't get the parameter SPPlatformFileSpecification*.
    Is there any other way to get the file path of background layer in my custom filter?
    Thanks,
    Dheeraj

    If this is a client side application then I'd say look into drag-n-drop tutorials.
    i.e. drag file to your application, action listener fires, create File object giving you full name and path of users action.
    If this is a web application then look into the "multipart/form-data" content type specifications on how to upload files.
    i.e. user specifies file from <input type='file' ... /> type, submits, servlet receives data and recreates file locally on application server side.
    If you are thinking that all you need to send a file to a program is the full path and name in a textbox its a little bit more complicated then that.
    Good luck, hope that helps!

  • How can I get my application Context Path?

    How can I get my application Context Path via webdynpro code?
    Let say I'm accesing my application with URL
    https://myapp:8443/webdynpro/dispatcher/local/MyApp/App, how can I get
    the value 'https://myapp:8443' from webdynpro code? In J2EE, this is
    equivalent of HttpServletRequest.getContextPath() method. Do we have
    this method call in webdynpro object?

    Hi John,
    Yes you can achieve that in Web Dynpro.
    Try the following -
    // USE THIS FOR GETTING THE SERVER NAME AND IMPORT WEBLOGIC.JAR FILE IN THE JAVA BUILD PATH PROPERTIES
    HttpServletRequest request = (( com.sap.tc.webdynpro.services.sal.adapter.core.IWebContextAdapter) WDWebContextAdapter.getWebContextAdapter()).getHttpServletRequest();
    //GETS THE HOST NAME OF THE SERVER
    String strHostName = request.getServerName();
    Thanks,
    Sam

  • How to get the current path of my application in java ?

    how to get the current path of my application in java ?
    thanks

    To get the path where your application has been installed you have to do the following:
    have a class called "what_ever" in the folder.
    then you do a litte:
    String path=
    what_ever.class.getRessource("what_ever.class").toString()
    That get you a string like:
    file:/C:/Program Files/Cool_program/what_ever.class
    Then you process the result a little to remove anything you don't want:
    path=path.substring(path.indexOf('/')+1),path.lastIndexOf('/'))
    //Might be a little error here but you should find out //quickly if it's the case
    And here you go, you have a nice
    C:/Program Files/Cool_program
    which is the path to your application.
    Hooray

  • How to get the ablolute path of the web application in WebSphere?

    How to get the ablolute path of the web application in WebSphere?
    For example:
    I have installed IBM WebSphere on D:\WebSphere\Appserver, and I created a new appliction named "myapp" on D:\myapp,. How can I get the absolute path of application "myapp"? In other words,how can I get the absolute path of the application's
    root directory?

    In the WebSphere(default), what directory is the Java Bean's root directory ?

  • How to get the application path?

    Does some body know how to get the application path in Java? Here is an example about what I'm thinking: Let's imagin the application is on "c:\try" or "c:\ProgramFiles\MyApp". My question is how can I find the path where the application is. Please give an example if you know the answer. Thank you so much.

    Those two replies give you some useful directories, it's true, but maybe not what the OP asked. However the OP asked for something that doesn't have a meaning (applications don't have to be "on" any directory, whatever that might mean).
    Would the OP like to describe what the actual problem is here?

  • How to get the enclosing folder of an Application?

    Ok. re-visiting my Applescript to compare installed apps versus a list of predefined apps... here is my test code so far:
    set appsPath to (path to applications folder)
    tell application "Finder"
      set appList to name of every application file of entire contents of folder appsPath
    end tell
    set theApps to {"iMovie.app", "Microsoft Excel", "Microsoft Excel.app", "Adobe Acrobat 7.0 Professional.app", "Adobe After Effects CS4.app", "ColorEyes Display Pro.app", "Corel Painter X.app", "DiskTracker 2.3.2", "EPSON Scan.app", "Flash 8.app", "Product Ingest.app", "Product Tag.app", "Art Ingest.app", "TextWrangler.app", "Toast Titanium.app", "Suitcase Fusion 2.app", "Suitcase Fusion 3.app", "Fetch.app"}
    repeat with anApp in theApps
      set vers to version of (application anApp)
      -- get parent path of anApp!!!!
      if (parentFolder is equal to "Applications" or parentFolder is equal to "Utilities") then
      set parentFolder to ""
      end if
      display alert anApp & ": Version: " & vers & " " & parentFolder
    end repeat
    The only thing I'm stuck on is how to get the parent folder of anApp. Basically we use several versions of software here that are not easily identifiable by the version attribute. However their enclosing folder has all the versioning info I need (e.g.: MS Excel 04's vers would be 110113, but the enclosing folder is "Microsoft Office 2004", and some departments get Office 2008, Office 2011, etc., so I need a human-friendly way to get the right versions)
    I don't know if the "if" statement to check whether the parent is Applications or Utilities is correct as I haven't gotten that far in testing. I'm only interested in getting the parent of apps that have parent folder that is a sub-folder of Applications or Utilities.
    Basically what I am trying to do here is write a text file containing all departmental apps, homefolder sizes, relevant partition sizes, etc. and spit it out at the tech responsible for migrating a user to a new mac (display alert is just convenient for testing purposes). In the past we've had too many "missed" items in QC like wrong apps installed, or wrong versions, or data not copied over properly, etc. So this way they can run this on the old system beforehand and the new system after, line everything up and check off if it matches. This is just a snippet...
    TIA!
    Andrew

    Hi,
    Andrew Caldwell wrote:
    Is there a way to invoke these without the script opening each one?
    You must use the bundle identifier instead of the name
    Here a example :
    set theApps to {"com.microsoft.excel", "com.adobe.Acrobat.Pro", "com.barebones.textwrangler", "com.roxio.Toast", "com.fetchsoftworks.Fetch"}
    repeat with anApp in theApps
           tell application "Finder" to tell (application file id anApp)
                  set vers to version
                  set parentFolder to name of its container
           end tell
           if parentFolder is in {"Applications", "Utilities"} then set parentFolder to ""
           display alert anApp & ": Version: " & vers & " " & parentFolder
    end repeat

Maybe you are looking for

  • Customizing Flash Web Gallery in Photoshop

    Hoping someone can help me... I'm at my wits end. I am doing a Flash Web Gallery in Photoshop, the second kind where the images "morph" into horizontal/vertical shapes. I need to make a couple of customizations to it:  First, I would like the TITLE o

  • SQL statement & ResulSet

    Hello all I got a request SQL to a data base. Every thing is fine, it returns me a resultset that i want to. My problem si when i try to do rs.getString() with a colomn number that i want to, it returns me just the 254 first characters instead of the

  • Error with Illustrator CS5.1 Outline Stroke & Path Finder

    Hey all I've recently been trying CS5.5 on Windows 7 64-bit. I've been playing around with it and have found that whenever I try to outline a stroke of a filled object, the fill moves slightly. Also when using Pathfinder the same type of error occurs

  • Finder icon previews slowing finder

    I work with a lot of pdf files, and as finder shows pdf icons as a preview of the first page it can take a long time before the content of a folder stabilises itself, ie: updates all icons with a preview of its content. Its particularly frustrating i

  • My screen is backwards!!!!

    If anyone has had this problem PLEASE let me know! Just about a year after I got my IPod mini (of course...) out of no where a black bar started scrolling down the screen...nothing showed up on the screen except that bar. I reset it and it seemed to