Struts link tag

Discussion in 'Java' started by GuyBrush Treepwood, May 15, 2005.

  1. I want to use the <html:link> tag to make a link to a certain webpage.
    The URL of this page is a string that is stored in the database. So how
    would I specify this string in my tag? For request parameters, one can use
    the paramId, paramName and paramProperty attributes. But can the url
    itself also be manipulated this way?

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 15, 2005
    #1
    1. Advertising

  2. GuyBrush Treepwood wrote:
    > I want to use the <html:link> tag to make a link to a certain webpage.
    > The URL of this page is a string that is stored in the database. So how
    > would I specify this string in my tag? For request parameters, one can use
    > the paramId, paramName and paramProperty attributes. But can the url
    > itself also be manipulated this way?
    >


    I am not sure if I understand this properly - you can use href or the
    page attribute to display web pages. You will have to read the value
    from the database and then store it is request scope, for example, and
    then

    <html:link href="<%= (String)request.getAttribute(\"url\") %>" ..../>

    The above solution using scriptlets is very ugly. If you are using
    struts-el:

    <html:link href="${requestScope.url}" ..../>

    Much better this time.

    The best solution is to use JSTL tags for this purpose instead of Struts
    tag. Use the <c:url ...> tag instead.

    The <html:link> tag is handy for defining forwards and actions otherwise
    JSTL tags are more flexible.

    --
    **********************************************************
    * Amit Chatterjee amit.chatterjee AT quik-j DOT com *
    * http://www.quik-computing.com *
    * QUIK Computing - Home of the Open Source Contact Center*
    **********************************************************
     
    Amit Chatterjee, May 15, 2005
    #2
    1. Advertising

  3. > The above solution using scriptlets is very ugly. If you are using
    > struts-el:
    >
    > <html:link href="${requestScope.url}" ..../>
    >
    > Much better this time.
    >
    > The best solution is to use JSTL tags for this purpose instead of Struts
    > tag. Use the <c:url ...> tag instead.
    >
    > The <html:link> tag is handy for defining forwards and actions otherwise
    > JSTL tags are more flexible.


    I already got a large portion of struts tags. Would it be bad to mix these
    JSTL tags with the already existing tags? I don't want to change all the
    tags because I'm running out of time. Maybe the struts-el is a better
    solution for me?

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 15, 2005
    #3
  4. GuyBrush Treepwood

    Wendy S Guest

    "GuyBrush Treepwood" <> wrote
    > I already got a large portion of struts tags. Would it be bad to mix these
    > JSTL tags with the already existing tags? I don't want to change all the
    > tags because I'm running out of time. Maybe the struts-el is a better
    > solution for me?


    Struts-EL is intended to be mixed with JSTL. If you look at the Struts-EL
    README file, it explains which JSTL tags you should use instead of the
    'classic' Struts tags. For example, use <c:eek:ut> instead of <bean:write>.

    --
    Wendy
     
    Wendy S, May 16, 2005
    #4
  5. On Sun, 15 May 2005 16:13:44 -0700, Wendy S wrote:

    > Struts-EL is intended to be mixed with JSTL. If you look at the Struts-EL
    > README file, it explains which JSTL tags you should use instead of the
    > 'classic' Struts tags. For example, use <c:eek:ut> instead of <bean:write>.


    Do I need all the jars listed at
    http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/standard-1.0/GettingStarted.html
    for using the jstl tag library? And where can I download a jar of the
    struts-el ? Can't seem to locate one.

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 16, 2005
    #5
  6. GuyBrush Treepwood wrote:
    > On Sun, 15 May 2005 16:13:44 -0700, Wendy S wrote:
    >
    >
    >>Struts-EL is intended to be mixed with JSTL. If you look at the Struts-EL
    >>README file, it explains which JSTL tags you should use instead of the
    >>'classic' Struts tags. For example, use <c:eek:ut> instead of <bean:write>.

    >
    >
    > Do I need all the jars listed at
    > http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/standard-1.0/GettingStarted.html
    > for using the jstl tag library? And where can I download a jar of the
    > struts-el ? Can't seem to locate one.
    >


    For JSTL, you will need the jstl.jar. The rest will depend on your
    requirements. I suggest you follow the instruction closely to avoid any
    confusion.

    Regarding Struts-el, the struts-el.jar is included with the Struts 1.2
    distribution. Include the jar in the WEB-INF/lib. If you used the
    web.xml to define aliases for the struts tags using the <taglib>
    element, modify the references to point to the struts-el and you should
    be all set.

    <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles-el.tld</taglib-location>
    </taglib>


    --
    **********************************************************
    * Amit Chatterjee amit.chatterjee AT quik-j DOT com *
    * http://www.quik-computing.com *
    * QUIK Computing - Home of the Open Source Contact Center*
    **********************************************************
     
    Amit Chatterjee, May 16, 2005
    #6
  7. GuyBrush Treepwood wrote:
    > On Sun, 15 May 2005 16:13:44 -0700, Wendy S wrote:
    >
    >
    >>Struts-EL is intended to be mixed with JSTL. If you look at the Struts-EL
    >>README file, it explains which JSTL tags you should use instead of the
    >>'classic' Struts tags. For example, use <c:eek:ut> instead of <bean:write>.

    >
    >
    > Do I need all the jars listed at
    > http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/standard-1.0/GettingStarted.html
    > for using the jstl tag library? And where can I download a jar of the
    > struts-el ? Can't seem to locate one.
    >


    For JSTL, you will need the jstl.jar. The rest will depend on your
    requirements. I suggest you follow the instruction closely to avoid any
    confusion.

    Regarding Struts-el, the struts-el.jar is included with the Struts 1.2
    distribution. Include the jar in the WEB-INF/lib. If you used the
    web.xml to define aliases for the struts tags using the <taglib>
    element, modify the references to point to the struts-el and you should
    be all set.

    <taglib>
    <taglib-uri>/tags/struts-bean</taglib-uri>
    <taglib-location>/WEB-INF/struts-bean-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-html</taglib-uri>
    <taglib-location>/WEB-INF/struts-html-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-logic</taglib-uri>
    <taglib-location>/WEB-INF/struts-logic-el.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-nested</taglib-uri>
    <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/tags/struts-tiles</taglib-uri>
    <taglib-location>/WEB-INF/struts-tiles-el.tld</taglib-location>
    </taglib>


    --
    **********************************************************
    * Amit Chatterjee amit.chatterjee AT quik-j DOT com *
    * http://www.quik-computing.com *
    * QUIK Computing - Home of the Open Source Contact Center*
    **********************************************************
     
    Amit Chatterjee, May 16, 2005
    #7
  8. GuyBrush Treepwood

    Wendy Smoak Guest

    "GuyBrush Treepwood" <> wrote:
    >
    > Do I need all the jars listed at
    >

    http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/standard-1.0/GettingStarted.html
    > for using the jstl tag library? And where can I download a jar of the
    > struts-el ? Can't seem to locate one.
    >


    Look in your distribution of Struts. You don't say what version you're
    using, but it's probably under the 'contrib' directory. What I do is copy
    all the .jar files from the 'lib' directory of the distribution, then copy
    all the .jar files from contrib/struts-el/lib. That's everything you need.

    http://struts.apache.org/userGuide/building_view.html#struts-el

    http://struts.apache.org/faqs/struts-el.html

    --
    Wendy
     
    Wendy Smoak, May 16, 2005
    #8
  9. GuyBrush Treepwood

    Wendy Smoak Guest

    "Amit Chatterjee" <amitDOTchatterjeeATquik-jDOTcom> wrote:

    > If you used the
    > web.xml to define aliases for the struts tags using the <taglib>
    > element, modify the references to point to the struts-el and you should
    > be all set.


    With a reasonably recent container, (Tomcat 4.1/Servlet 2.3) you no longer
    have to define the tld's in web.xml. The tld will be located inside the
    ..jar file if you use the correct uri, for example:

    <%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el"
    prefix="html-el" %>

    --
    Wendy
     
    Wendy Smoak, May 16, 2005
    #9
  10. On Mon, 16 May 2005 08:46:11 -0700, Wendy Smoak wrote:

    > "GuyBrush Treepwood" <> wrote:
    >>
    >> Do I need all the jars listed at
    >>

    > http://jakarta.apache.org/taglibs/doc/standard-1.0-doc/standard-1.0/GettingStarted.html
    >> for using the jstl tag library? And where can I download a jar of the
    >> struts-el ? Can't seem to locate one.
    >>

    >
    > Look in your distribution of Struts. You don't say what version you're
    > using, but it's probably under the 'contrib' directory. What I do is copy
    > all the .jar files from the 'lib' directory of the distribution, then copy
    > all the .jar files from contrib/struts-el/lib. That's everything you need.
    >
    > http://struts.apache.org/userGuide/building_view.html#struts-el
    >
    > http://struts.apache.org/faqs/struts-el.html


    I used the library version of struts 1.2.4, but struts-el wasn't in there.
    It is in the binary download though. Thanks a lot for the help.

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 16, 2005
    #10
  11. Wendy Smoak wrote:
    > "Amit Chatterjee" <amitDOTchatterjeeATquik-jDOTcom> wrote:
    >
    >
    >>If you used the
    >>web.xml to define aliases for the struts tags using the <taglib>
    >>element, modify the references to point to the struts-el and you should
    >>be all set.

    >
    >
    > With a reasonably recent container, (Tomcat 4.1/Servlet 2.3) you no longer
    > have to define the tld's in web.xml. The tld will be located inside the
    > .jar file if you use the correct uri, for example:
    >
    > <%@ taglib uri="http://jakarta.apache.org/struts/tags-html-el"
    > prefix="html-el" %>
    >


    That is correct. However, I prefer to use the name <html:xxx> instead of
    <html-el:xxx> even if I am using the struts-el tags. This "-el" prefix
    can be tedious :).



    --
    **********************************************************
    * Amit Chatterjee amit.chatterjee AT quik-j DOT com *
    * http://www.quik-computing.com *
    * QUIK Computing - Home of the Open Source Contact Center*
    **********************************************************
     
    Amit Chatterjee, May 17, 2005
    #11
  12. On Sun, 15 May 2005 06:17:15 -0400, Amit Chatterjee wrote:

    > GuyBrush Treepwood wrote:
    >> I want to use the <html:link> tag to make a link to a certain webpage.
    >> The URL of this page is a string that is stored in the database. So how
    >> would I specify this string in my tag? For request parameters, one can use
    >> the paramId, paramName and paramProperty attributes. But can the url
    >> itself also be manipulated this way?
    >>

    >
    > I am not sure if I understand this properly - you can use href or the
    > page attribute to display web pages. You will have to read the value
    > from the database and then store it is request scope, for example, and
    > then
    >
    > <html:link href="<%= (String)request.getAttribute(\"url\") %>" ..../>


    >
    > The above solution using scriptlets is very ugly. If you are using
    > struts-el:
    >
    > <html:link href="${requestScope.url}" ..../>
    >
    > Much better this time.
    >
    > The best solution is to use JSTL tags for this purpose instead of Struts
    > tag. Use the <c:url ...> tag instead.
    >
    > The <html:link> tag is handy for defining forwards and actions otherwise
    > JSTL tags are more flexible.


    The problem I have is: I can't use the ${...} because I use
    the Jakarta implementation of JSTL 1.0. If need the implementation of 2.0
    to use the ${} expressions, but the Tomcat implementation I use is version
    4.3, and it's not in my power to upgrade it.

    It's probably the only place in my views where I would use a scriptlet.
    Has it other disadvantages besides being ugly?

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 17, 2005
    #12
  13. GuyBrush Treepwood

    Wendy Smoak Guest

    "GuyBrush Treepwood" <> wrote
    >
    > The problem I have is: I can't use the ${...} because I use
    > the Jakarta implementation of JSTL 1.0. If need the implementation of 2.0
    > to use the ${} expressions, but the Tomcat implementation I use is version
    > 4.3, and it's not in my power to upgrade it.


    That doesn't make sense. (Not least because there is no Tomcat 4.3.)

    Can you post what you've tried that isn't working? I'm not sure why you
    think you can't use ${} expressions with JSTL 1.0.

    The '2.0' you're referring to must be JSP 2.0 (not JSTL!). JSP 2.0 allows
    you to use expressions anywhere in the page.

    --
    Wendy
     
    Wendy Smoak, May 17, 2005
    #13
  14. On Tue, 17 May 2005 08:45:29 -0700, Wendy Smoak wrote:

    > "GuyBrush Treepwood" <> wrote
    >>
    >> The problem I have is: I can't use the ${...} because I use
    >> the Jakarta implementation of JSTL 1.0. If need the implementation of 2.0
    >> to use the ${} expressions, but the Tomcat implementation I use is version
    >> 4.3, and it's not in my power to upgrade it.

    >
    > That doesn't make sense. (Not least because there is no Tomcat 4.3.)


    Sorry, Tomcat 4.1.3

    >
    > Can you post what you've tried that isn't working? I'm not sure why you
    > think you can't use ${} expressions with JSTL 1.0.


    <taglib>
    <taglib-uri>/c-rt</taglib-uri>
    <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
    </taglib>

    <%@ taglib uri="/c-rt" prefix="c" %>
    <logic:present name="accountBean" scope="session">
    <c:if test="${sessionScope.accountBean.authenticated != true}">
    <html:link page="/service/signonForm.do">Sign On</html:link>|
    <html:link page="/service/newAccountForm.do">Register</html:link>
    </c:if>
    </logic:present>

    I don't get any errors, but it just doesn't interpret the ${}.
    When I put this in the page:

    <c:eek:ut value="${sessionScope.accountBean.username}", the ${} part is
    displayed literally the page.

    >
    > The '2.0' you're referring to must be JSP 2.0 (not JSTL!). JSP 2.0
    > allows you to use expressions anywhere in the page.


    It indeed does. I misread this on the taglibs site. I now see my problem
    hasn't anything to do with versions. But what's the problem? I really
    can't see it.

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 17, 2005
    #14
  15. On Tue, 17 May 2005 19:24:02 +0200, GuyBrush Treepwood wrote:

    > On Tue, 17 May 2005 08:45:29 -0700, Wendy Smoak wrote:


    >> Can you post what you've tried that isn't working? I'm not sure why you
    >> think you can't use ${} expressions with JSTL 1.0.

    >
    > <taglib>
    > <taglib-uri>/c-rt</taglib-uri>
    > <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
    > </taglib>
    >
    > <%@ taglib uri="/c-rt" prefix="c" %>
    > <logic:present name="accountBean" scope="session">
    > <c:if test="${sessionScope.accountBean.authenticated != true}">
    > <html:link page="/service/signonForm.do">Sign On</html:link>|
    > <html:link page="/service/newAccountForm.do">Register</html:link>
    > </c:if>
    > </logic:present>


    Of course I also included the struts-el taglibs.

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 17, 2005
    #15
  16. GuyBrush Treepwood

    Wendy Smoak Guest

    "GuyBrush Treepwood" <> wrote
    > <taglib>
    > <taglib-uri>/c-rt</taglib-uri>
    > <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
    > </taglib>


    No wonder! You're using the 'rt' version of the taglib, which doesn't
    recognize expressions.

    Here's a mailing list thread which should be helpful:
    http://www.mail-archive.com//msg49488.html

    Suggestion, get rid of the "loose" tlds under WEB-INF, remove the <taglib>
    tags from web.xml, and use this in the JSP:
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"
    %>

    Similarly with Struts-EL, for example:
    <%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html-el"
    %>

    Your expressions should start working if you use the 'regular' version of
    JSTL.

    --
    Wendy Smoak
     
    Wendy Smoak, May 17, 2005
    #16
  17. On Tue, 17 May 2005 10:54:44 -0700, Wendy Smoak wrote:

    > "GuyBrush Treepwood" <> wrote
    >> <taglib>
    >> <taglib-uri>/c-rt</taglib-uri>
    >> <taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>
    >> </taglib>

    >
    > No wonder! You're using the 'rt' version of the taglib, which doesn't
    > recognize expressions.
    >
    > Here's a mailing list thread which should be helpful:
    > http://www.mail-archive.com//msg49488.html
    >
    > Suggestion, get rid of the "loose" tlds under WEB-INF, remove the <taglib>
    > tags from web.xml, and use this in the JSP:
    > <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"
    > %>
    >
    > Similarly with Struts-EL, for example:
    > <%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html-el"
    > %>
    >
    > Your expressions should start working if you use the 'regular' version of
    > JSTL.


    I did as you told me, and everything seemed to work. But now, I want to
    set a security constraint so users cannot access .jsp pages directly,
    except for the /index.jsp. All the other files are in subdirectories, so:

    <security-constraint>
    <web-resource-collection>
    <web-resource-name>no_access</web-resource-name>
    <url-pattern>/*/*.jsp</url-pattern>
    </web-resource-collection>
    <auth-constraint/>
    </security-constraint>

    However, if I want to test this by going to:

    http://blabladomain/bookmarks/Folder.jsp

    I get following error:

    org.apache.jasper.JasperException: /bookmarks/Folder.jsp(0,0) This
    absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either
    web.xml or the jar files deployed with this application

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 18, 2005
    #17
  18. GuyBrush Treepwood

    Wendy S Guest

    "GuyBrush Treepwood" <> wrote

    > I did as you told me, and everything seemed to work. But now, I want to
    > set a security constraint so users cannot access .jsp pages directly,
    > except for the /index.jsp. All the other files are in subdirectories, so:
    >
    > <security-constraint>
    > <web-resource-collection>
    > <web-resource-name>no_access</web-resource-name>
    > <url-pattern>/*/*.jsp</url-pattern>
    > </web-resource-collection>
    > <auth-constraint/>
    > </security-constraint>
    >
    > However, if I want to test this by going to:
    > http://blabladomain/bookmarks/Folder.jsp
    > I get following error:
    >
    > org.apache.jasper.JasperException: /bookmarks/Folder.jsp(0,0) This
    > absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either
    > web.xml or the jar files deployed with this application


    One thing at a time! Does the page work *without* the security constraint?
    (What does 'everything seemed to work' mean? Were you getting expressions
    evaluated, or not?)

    The error message says it can't find the tld. Look in all the .jar files
    you've got and make sure that there is a tld with that uri in it. It's in
    standard.jar on my system, and the filename is c.tld. Make sure you have
    exactly one of these.

    (To look inside jar files, you can do
    jar -tvf filename.jar
    and it will print out the contents.)

    You're on Tomcat 4.1, right? It _should_ work, but you can always go back
    to mapping the tlds in web.xml while you work out the rest of the issues.

    On to your security constraint. The URL you are using for your security
    constraint is wrong. Read SRV.11.2 of the Servlet Specification-- it's not
    a regular expression, it's a pattern with some specific, very limited rules.
    There are only three patterns that it recognizes, anything else is an exact
    match.

    http://java.sun.com/products/servlet/reference/api/index.html#specs (Get
    version 2.3 for Tomcat 4.1)

    --
    Wendy
     
    Wendy S, May 18, 2005
    #18
  19. On Tue, 17 May 2005 22:22:23 -0700, Wendy S wrote:

    > "GuyBrush Treepwood" <> wrote
    >
    >> I did as you told me, and everything seemed to work. But now, I want to
    >> set a security constraint so users cannot access .jsp pages directly,
    >> except for the /index.jsp. All the other files are in subdirectories, so:
    >>
    >> <security-constraint>
    >> <web-resource-collection>
    >> <web-resource-name>no_access</web-resource-name>
    >> <url-pattern>/*/*.jsp</url-pattern>
    >> </web-resource-collection>
    >> <auth-constraint/>
    >> </security-constraint>
    >>
    >> However, if I want to test this by going to:
    >> http://blabladomain/bookmarks/Folder.jsp
    >> I get following error:
    >>
    >> org.apache.jasper.JasperException: /bookmarks/Folder.jsp(0,0) This
    >> absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either
    >> web.xml or the jar files deployed with this application

    >
    > One thing at a time! Does the page work *without* the security constraint?
    > (What does 'everything seemed to work' mean? Were you getting expressions
    > evaluated, or not?)


    Yes, my expressions were evaluated and I did not get the same error as
    with the security constraint.

    >
    > The error message says it can't find the tld. Look in all the .jar files
    > you've got and make sure that there is a tld with that uri in it. It's in
    > standard.jar on my system, and the filename is c.tld. Make sure you have
    > exactly one of these.


    Yes, it is present.

    >
    > You're on Tomcat 4.1, right? It _should_ work, but you can always go back
    > to mapping the tlds in web.xml while you work out the rest of the issues.
    >
    > On to your security constraint. The URL you are using for your security
    > constraint is wrong. Read SRV.11.2 of the Servlet Specification-- it's not
    > a regular expression, it's a pattern with some specific, very limited rules.
    > There are only three patterns that it recognizes, anything else is an exact
    > match.
    >
    > http://java.sun.com/products/servlet/reference/api/index.html#specs (Get
    > version 2.3 for Tomcat 4.1)


    Because I don't get the error without the security constraint, it must be
    because of the wrong URL pattern.

    --
    "Don't worry about people stealing your ideas. If your ideas are any good,
    you'll have to ram them down people's throats."
    -- Howard Aiken
     
    GuyBrush Treepwood, May 18, 2005
    #19
  20. Try with

    <url-pattern>*.jsp</url-pattern>

    instead of

    <url-pattern>/*/*.jsp</url-pattern>


    GuyBrush Treepwood wrote:
    > On Tue, 17 May 2005 22:22:23 -0700, Wendy S wrote:
    >
    >
    >>"GuyBrush Treepwood" <> wrote
    >>
    >>
    >>>I did as you told me, and everything seemed to work. But now, I want to
    >>>set a security constraint so users cannot access .jsp pages directly,
    >>>except for the /index.jsp. All the other files are in subdirectories, so:
    >>>
    >>> <security-constraint>
    >>> <web-resource-collection>
    >>> <web-resource-name>no_access</web-resource-name>
    >>> <url-pattern>/*/*.jsp</url-pattern>
    >>> </web-resource-collection>
    >>> <auth-constraint/>
    >>> </security-constraint>
    >>>
    >>>However, if I want to test this by going to:
    >>>http://blabladomain/bookmarks/Folder.jsp
    >>>I get following error:
    >>>
    >>>org.apache.jasper.JasperException: /bookmarks/Folder.jsp(0,0) This
    >>>absolute uri (http://java.sun.com/jstl/core) cannot be resolved in either
    >>>web.xml or the jar files deployed with this application

    >>
    >>One thing at a time! Does the page work *without* the security constraint?
    >>(What does 'everything seemed to work' mean? Were you getting expressions
    >>evaluated, or not?)

    >
    >
    > Yes, my expressions were evaluated and I did not get the same error as
    > with the security constraint.
    >
    >
    >>The error message says it can't find the tld. Look in all the .jar files
    >>you've got and make sure that there is a tld with that uri in it. It's in
    >>standard.jar on my system, and the filename is c.tld. Make sure you have
    >>exactly one of these.

    >
    >
    > Yes, it is present.
    >
    >
    >>You're on Tomcat 4.1, right? It _should_ work, but you can always go back
    >>to mapping the tlds in web.xml while you work out the rest of the issues.
    >>
    >>On to your security constraint. The URL you are using for your security
    >>constraint is wrong. Read SRV.11.2 of the Servlet Specification-- it's not
    >>a regular expression, it's a pattern with some specific, very limited rules.
    >>There are only three patterns that it recognizes, anything else is an exact
    >>match.
    >>
    >> http://java.sun.com/products/servlet/reference/api/index.html#specs (Get
    >>version 2.3 for Tomcat 4.1)

    >
    >
    > Because I don't get the error without the security constraint, it must be
    > because of the wrong URL pattern.
    >



    --
    **********************************************************
    * Amit Chatterjee amit.chatterjee AT quik-j DOT com *
    * http://www.quik-computing.com *
    * QUIK Computing - Home of the Open Source Contact Center*
    **********************************************************
     
    Amit Chatterjee, May 18, 2005
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    860
    Kevin Spencer
    May 17, 2005
  2. kishan bisht

    struts tag inside a tag

    kishan bisht, Jul 8, 2003, in forum: Java
    Replies:
    1
    Views:
    1,489
    Wendy S
    Jul 9, 2003
  3. Katie Wright
    Replies:
    8
    Views:
    4,256
    Andrea Desole
    Jan 7, 2005
  4. shruds
    Replies:
    1
    Views:
    834
    John C. Bollinger
    Jan 27, 2006
  5. Replies:
    1
    Views:
    6,080
    Andrew T.
    Jul 10, 2006
Loading...

Share This Page