Request.getRequestURL() equivalent in JSTL

Hi,
I am starting to mess with jstl. I was wondering if there is a "request.getRequestURL() " equivalent in JSTL. I have been messing with the implicit objects and do not seem to be able to find the url information in there. I can manually put the string together by putting different fields together, but that seems to be less than graceful.
If not, how would I handle this best? Break down and use a <%...%>, send a request to my model and have a form bean send back the url? I seem to be missing something.
Thanks,
Jim S.

EL doesn't define an implicit request object, but it does reveal the pageContext.
You can get hold of the request object via ${pageContext.request}
request.getRequestURL() is equivalent to ${pageContext.request.requestURL}
Cheers,
evnafets

Similar Messages

  • Java EE 5 request.getRequestURL() change

    Hello,
    I have a problem with change of the method HttpServletRequest.getRequestURL() in my action servlets. I have this situation:
    URL matches http://server/app/page-key-word-string
    These URLs generates 404 Tomcat error page, which redirects to redirectServlet, where I get the client URL by calling request.getRequestURL() and then I parse the page-key-word-string and select the matching page from DB.
    This worked fine in Java EE 1.4 but in Java EE 5 the getRequestURL() method returns the path to redirectServlet instead of the client URL. Please, where can I get the client URL? Or is there other way to implement these functionality?
    Thanks a lot.

    Hmm.. Do you mean response.redirect() or forward via RequestDispatcher? A redirect issues a new GET request from the client, changing the url returned from getRequestURL() so the behavior via J2EE 5 is more understandable. I'm not sure how the process worked for you using J2EE 4 unless you were using the RequestDispatcher and changed your code... But maybe there's more to this..

  • Equivalent of JSTL / JSF variables in ADF Faces

    Is there any equivalent of JSTL core variables <c:set property="" value="" /> in ADF faces? ...The problem with those JSTL variables are they are immediate expressions ($) and they cannot be used with EL expressions in ADF component properties, as they deal with {# defered}..We have <f:attribute> which we add that to any component, but can retrived only using from backend code when any events are generated. like event.getComponent().getAttributes()....
    I am looking for some declarative attribute which holds some value within jsff page fragment....(not the one like managed bean attribute)

    Yes, We can use keep the variable in viewScope....But how do you define any variable in jsff declaratively in that viewScope (not using any backing bean method) .....if you see <c:set > you can define that in page and use it across.....I cant use property listener or action listener ..as i can set these values only on invoking certain action on a component....i want to set them based on certain condition like using c:if and not on some action...I dont see any way other than using some backing bean and binding with some property and setting some value...

  • Cannot reliably use request.getRequestURL() in my backing bean

    I am using jDev 11.1.2.3.0.
    In my backing bean to my ADF JSF page fragment I get mixed results from different web browsers when trying to retrieve a URL from the request object. The java code I use in my bean is like this:
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)fc.getExternalContext().getRequest();
    String URL = request.getRequestURL().toString();
    Depending on whether I use IE, Firefox or Chrome, sometimes the URL = null. What's wierder is that different computers in my office get different results. One computer can get URL = null in IE and FF, and another would get null using Chrome and IE. It's so bizzare, I don't even know where to start debugging this issue.
    But I'm wondering if it's the way I am retrieving the request object using request = (HttpServletRequest)fc.getExternalContext().getRequest(); Is this the right way to get the request object?

    Hi,
    if you are in a page fragment then the request is partial anyway. So can you give us an idea of what the use case is for which you need the URL ? Maybe its easier to fix the desired use case implementation then to fix access to the URL just to find out you cannot use the result (the URL is not identifying the page fragment and thus doesn't allow redirects or bookmarks)
    Frank

  • OAS request.getRequestURL() sometimes gives port 0 instead of proper port

    I've implemented a Single Sign On system between two systems -- one (not OAS) generates an encrypted token using some Oracle pl/sql and passes it as a URL parameter, the other (OAS 10.1.2) receives it, decodes and validates, and then does a redirect to push the user into our system.
    I'm using standard Java methods etc and the code which constructs the redirect URL "generally" works, but sometimes, instead of giving me the proper port number in the URL (7873), it randomly puts a 0 in instead. I'm not positive what causes it, so I'm unable to provide a repeatable test which causes the port 0 to appear consistently.
    StringBuffer reqURL = request.getRequestURL();
    log.info("reqURL: " + reqURL.toString());
    (snip)
    response.sendRedirect(url.toString());
    I wrote code to find the :0 and remove it, but I'm wondering where exactly its coming from (seems like a bug in OAS), and if anyone has seen it themselves and knows how to fix it.
    Thanks!

    We believe this issue is related to the version of Apache and mod_oc4j which are included with OHS 10.1.2.
    We are upgrading to OHS 10.1.3 and hope this resolves the troubles. We have already tested with Apache 2.0.59 and cannot recreate this issue.

  • Is there a logic:match equivalent for JSTL?

    In a search page I execute a query which returns an array of objects (All objects are of the same object type and are cast to Object[]) and each object has many attributes. I tried using <logic:iterate>, but I was never successful in having it display any results. I believe this had something to do with the entire array being passed via session scope instead of just one record and me not specifying it properly with <logic:iterate>. I was able to successfully use <c:forEach> and it worked right away. I stuck with using that because of its "just works" ability in addition to using a lot of other JSTL code. However, one of the attributes that is being printed out needs to be parsed and is of the form "Yxxx". <logic:match> covers this very nicely, but when I specify it in the below code it is not able to find my variable in any scope.
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
        <logic:match parameter='${myResults}' property='pin' value='Y'>
            <c:out value="Preeti"/>
        </logic:match>
    </c:forEach>I have done several google searches, but I haven't found a JSTL equivalent for <logic:match>. If there is one could someone please tell me what it is? In addition, although <logic:match> is great I still need to print out a substring of that attribute. Could someone tell me how to do that? If this is not possible could someone please tell me if its possible to use <logic:iterate> with an array of objects like I was attempting to do initially so that I could use <logic:match> at least?
    Thanks to all of you for your time.

    Yes you can use the logic:iterate tag. I think you have to specify the type of the exposed variable though. I prefer the forEach loop.
    I think you are using the wrong attribute in the logic:match tag. You should be using the "name" attribute rather than "parameter"
    Parameter attribute refers you to a request parameter, and I pretty sure you don't want that.
    So given the collection of objects in the session attribute "result"
    This should loop through them all, and see if they start with the letter 'Y'
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
        <logic:match name='myResults' property='pin' value='Y'>
            <c:out value="Preeti"/>
        </logic:match>
    </c:forEach>As for the latter bit, are you using a JSP2 container and JSTL1.1? It would appear so seeing as you are trying to use EL expressions in the logic:match tag.
    If so, you could make use of the JSTL function library:
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
       <c:if test='${fn:startsWith(myResults.pin, "Y")}'>
          <c:out value="${fn:substring(myResults.pin, 1, -1)}"/>
        </c:if>
    </c:forEach>And I've just spotted a very cool function in there: substringAfter
    <c:forEach var="myResults" items="${sessionScope.result}" varStatus="status">
          <c:out value='${fn:substringAfter(myResults.pin, 'Y')}'/>
    </c:forEach>Cheers,
    evnafets

  • UIX JSP equivalent for JSTL 'set'?

    Is there a UIX JSP tag that performs an analogous function to the JSTL tag 'set'? I would like to be able to setup local variables so that I don't have to repeat extended expressions.

    You can (generally) speaking use JSTL's set in UIX JSP pages, and (mostly) use JSTL JSP tags with UIX JSP tags.
    So, you should just be able to use <c:set>.
    The major complexity in integrating the two is remembering that JSTL sets and iterates immediately, but UIX JSP evaluates EL expressions only once the last UIX JSP tag completes. This doesn't cause much of a problem with <c:set> or <c:if>, but does cause some major problems with <c:forEach>.
    (A very similar problem is encountered when using JSTL tags with Java Server Faces JSP tags, so this is just a painful fact-of-life.)

  • JSTL to access url string

    Hi All,
    Is it possible to access the url string using jstl ? What about the equivalent to the jsp code 'request.getRequestURL()' in jstl ?
    Any pointers ? Much Appreciated...

    You can get at the request object through the pageContext
    ${pageContext.request.requestURL}
    Cheers,
    evnafets

  • How to get the URL of the request.

    I am trying to get the URL from where the request is coming to the servlet. If http://www.xx.com/ calls my servlet i want to know that the request is coming from http://www.xx.com/ URL. If i use request.getRequestURL() which is displaying my servlet URL. Please help me which is very urgent.

    You actually want the referrer? You can obtain it from the request headers as follows:String referrer = request.getHeader("referer"); // Yes, with the legendaric misspelling in there.Having said that, be aware that the client has full control over what he sends with the request headers. So the client can change/spoof/remove the referrer entry to his taste anytime. Your code should not rely that much on it, it should rather be used for statistics only.

  • JSTL: Using value of a variable in expression

    All, I am stuck on this problem and I hope someone here can help. This is a real tough one for me to explain but I'l try my best.
    I am try to have my includes a little more component oriented. So I wanted to use something like the following
    <c:import url="/somedir/outputusers.jsp">
    <c:param name="collection">users</c:param>
    </c:import>
    I would like to use the value of a request parameter in a JSTL expression. For example, say I have a Collection of objects implementing the User interface in the request under the name 'users'. Normally in JSTL I can reference it by ${users}. Now say I wrote a JSP page that will display any collection of objects that implement "User". I would like to use something like above to pass in the name of the variable in request scope, that points to the collection of User objects, i.e. "users". Then in the included jsp I would use JSTL to loop through the collection and output it in HTML.
    The problem is I cannot find any want of doing it. It would probably look something like this:
    <c:forEach var="user" items="${ ${param.collection} }">
    Any ideas?
    Steve

    In the worst case, you could always resort to using scriptlets to retrieve the parameter. and set it up as an attribute in the local page scope.
    <%
    String param = (String)request.getParameter("collection");
    Collection userCollection = (Collection)request.getAttribute(param);
    pageContext.setAttribute("local_collection", userCollection);
    %>
    <forEach var="user" items="${local_collection}">
    ,,,I think this should work.
    JSTL is great, but it can't yet replace every scriptlet, much as I would like it to.

  • Accessing the value in option Tag in html using JSTL

    Hi,
    Following is my code
    <select>
    <option value="1">one </option>
    <option value="2">Two</option>
    </select>
    Now, if I select two from the option, i need to get the value 2, using JSTL( JSP standard Tag Library).
    Can someone help me out.
    Thanks
    Achillies.

    You need to give the "select" component a name to submit under.
    <select name="yourChoice">
      <option value="1">one </option>
      <option value="2">Two</option>
    </select>When you submit this page, it will submit a parameter like yourChoice=2.
    In a servlet you retrieve this with request.getParameter("yourChoice");
    In JSTL/EL, you can use the param map: ${param.yourChoice}

  • WL 6.1sp1&sp2 BUG: HttpServletRequest.getRequestURL()

              HttpServletRequest.getRequestURL() always returns "http://..." even if the request
              was made with "https://...". The fix is to replace the protocol specification with
              the results from getScheme() like so:
              StringBuffer aURL = request.getRequestURL();
              // broken on WL 6.1 -- need to correct the scheme
              aURL = aURL.replace(0, aURL.toString().indexOf(':'),
              request.getScheme());
              

    Tonna I wrote:
              > Hi there,
              > Which version was this bug resolved in? Is it still outstanding in WL6.1sp4?
              > We?re currently using WL6.1sp2?if it?s resolved in WL6.1SP4 we may consider upgrading
              > instead of putting in a fix.
              >
              > Cheers
              > Tonna
              >
              > Nagesh Susarla <[email protected]> wrote:
              >
              >>thanks for pointing this out!
              >>its indeed a bug
              >>
              >>Steve Ditlinger wrote:
              >>
              >>>HttpServletRequest.getRequestURL() always returns "http://..." even
              >>
              >>if the request
              >>
              >>>was made with "https://...". The fix is to replace the protocol specification
              >>
              >>with
              >>
              >>>the results from getScheme() like so:
              >>>
              >>> StringBuffer aURL = request.getRequestURL();
              >>> // broken on WL 6.1 -- need to correct the scheme
              >>> aURL = aURL.replace(0, aURL.toString().indexOf(':'),
              >>>request.getScheme());
              >
              >
              Yes the fix is a part of 61sp4. If you still have any issues with the
              above mentioned problem, or if you need a patch please contact support
              the associated bug-id : CR076389
              rgds
              Nagesh
              

  • GetRequestURL() problem

    Hi all,
    I've a problem with getRequestURL().
    I've an address like this : "https://www.testtest.com", but when I invoke request.getRequestURL() I receive in http so "http://www.testtest.com".
    What could be the problem? Could it be something about java.security?
    thanks in advance.

    wkgrp wrote:
    How can i check this to be sure?If you didn't install it, then ask the person who did install it. If you did install it then no, you're not running a separate HTTP server in front of the servlet container. Unless you install things without knowing about it :/
    Note that this is not the IBM forum, its on their own website. There you'll find people who use Websphere, who might just know how to help you.

  • How to create request object manually?

    Can i edit a servlet request at the front controller level and disptach it to real url?
    I need the way(maybe a class) to edit the request parameters;
             request.getContextPath();
             request.getRequestURL();
             request.getPathInfo();
             request.getServletPath();i need the equvilance of these methods which are built to SET.
    is it possible?
    thank you

    1) Write a subclass of the HttpServletRequestWrapper
    class and overide your required methods.http://forum.java.sun.com/thread.jspa?threadID=682565&tstart=100
    I have used the wrapper in that forum but this is just for to set some Parameter to the request. But there is no method like setServletPath on the wrapper class? it is still missing and i need an HELP plz about how to override ServletPath on the request object.
    2)In the doFilter() method of your filter, call
    chain.doFilter() method giving your wrapped request
    object as an argument.I did it
      public void doFilter(ServletRequest req,ServletResponse res,FilterChain chain)throws IOException,ServletException {
           HttpServletRequest request = (HttpServletRequest) req;       
          HttpRequestWithModifiableParameters myReq= new HttpRequestWithModifiableParameters(request);
          request=(HttpServletRequest)myReq;
          HttpServletResponse response=(HttpServletResponse)res;
          chain.doFilter( request, response );
      }please help about just only how to override ServletPath on request object!!
    thank you

  • How can a servlet determine the exact requesting URL

    This seems like a simple question, but I cannot find a solution. I am wondering how a servlet can determine the exact requesting URL that invoked the servlet. Specifically, I am having trouble making my servlet determine if the port number was specified or not. I am using session tracking, and my web server (by default) produces two separate sessions when hitting https://myserver.com/myservlet and https://myserver.com:443/myservlet.
    I have tried to use the HttpUtils.getRequestURL(), but this function seems to assume that if you used https over port 443, that you DID NOT specify 443 in the URL.
    SV

    If your servlet container implements servlet 2.2 or better, try the request.getRequestURL() method. It should return everything that was originally entered for the request address at the client except the query string (use request.getQueryString() to get that).
    I am not sure how it handles the port number for specifically entered vs not specifically entered.

Maybe you are looking for

  • How to check table difference QUICKLY?( symetic check, hash check, or ...)

    Hi. Everyone. I would like to know whether or not there is a difference between tables. The two tables are located at the differerent location, and network speed is very bad. I am considering this two ways as belows. 1. symeteric check (select * from

  • Populate row of master detail form with selection from LOV?

    Hi Guys, Total noobe, Hope you can help me out with a project I am working on in Oracle Apex 4.1 with 11g XE I am sure this is a simple enough issue but I just can’t see the solution. I have a table called ‘STOCK’ this contains all new parts and deli

  • Refresh table automatically after adding record in dynpro

    I have a table element in my layout which is bind to a dictionary table and displaying the records correctly.I have input fields in the same view along with the add buttoon which inserts the entered record into the dictionary table successfully. Till

  • H264 HD Color Shift

    I've searched the forums and found some references to something similar having to do with h264's encoding for HD and SD differently with rec601 and rec709 (http://forums.adobe.com/thread/769015) but we seem to have the opposite problem where outputti

  • Create WCS guest accounts

    Hi I like to know if some one has some solution or input to my questions below Is there a way to auto generate user and password for guest accounts? So that you don't have to write in username just click on generate accont and WCS make up a username