> -----Original Message-----
> From: Erik Weber [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, July 21, 2004 11:32 AM
> To: Struts Users Mailing List
> Subject: Re: Tag question
> 
> 
> Sorry, I should have explained better what I am doing.
> 
> My controller Servlet is mapped to /services/*
> 
> All requests for JSP pages go through the controller, via action 
> mappings. The actions have paths like:
> 
> /usecase/view_edit_page
> /usecase/save_existing_record
> /usecase/view_add_page
> /usecase/add_new_record
> 
> So the full links look like:
> 
> <context>/services/usecase/view_edit_page
> 
> meanhwhile other resources have paths like:
> 
> <context>/images/some_image.gif
> 
> This keeps other resources out of the scope of the controller (and 
> perhaps into the scope of some other servlet). Also, direct 
> JSP access 
> is prohibited.
> 
> So in places where I am building hyperlinks (within JSPs), I 
> need to get 
> "/services" into each link, in front of the action URI, but 
> behind the 
> context. And I want to do this in a portable way (in case the Servlet 
> mapping changes).

If you use html:link and forwards then you can do whatever you want, and won't have to 
change the links themselves.  This would be pretty portable as well.

> 
> So the idea is to put something like <html:rewrite 
> page="${controller_path}<action_URI_here>"> which literally would be 
> "/services" + "/usecase/action" or 
> "/services/usecase/action". Using the 
> "page" attribute to the tag makes it come out right 
> ("/context/services/usecase/action").
> 
> (When I say "usecase" here I really should say "collection of 
> usecases" 
> or "function group" to be more accurate).
> 
> I would be interested in hearing other mapping strategies. 

I map jsp and directories by actor rather then use case, or use case package.  Makes 
everything easier (especially declaritive security, then again I've kept the *.do 
mapping, rather then what you're doing.
That would make your url something like services/actor/useCase, which doesn't get 
around your problem.

> For now I'm 
> making sure the JSP can call a method or access a variable 
> that returns 
> "/services".
> 
> Erik
> 
> 
> 
> Christian D Hahn wrote:
> 
> > Are you mapping the jsp to /services in the web.xml? if you do, 
> > getServletPath should return the path you are looking for.
> >
> > <servlet>
> > <servlet-name>jsp</servlet-name>
> > <jsp-file>/usecase/page.jsp</jsp-file>
> > </servlet>
> >
> > <servlet-mapping>
> > <servlet-name>jsp</servlet-name>
> > <url-pattern>/services</url-pattern>
> > </servlet-mapping>
> >
> > -Chris
> >
> > Erik Weber wrote:
> >
> >> Hmm I must be doing something wrong. That's giving me the 
> same value 
> >> as Erez's example. Strange, I would have expected it to give me 
> >> "/services". I wonder how I am causing it to give me 
> >> "/usecase/page.jsp".
> >>
> >> atta-ur rehman wrote:
> >>
> >>> Hi Erik,
> >>>
> >>> This one worked for me:
> >>>
> >>> <c:set var="v">
> >>> <%= request.getServletPath() %>
> >>> </c:set>
> >>>
> >>> <c:out value="${v}"/>
> >>> <bean:write name="v"/>
> >>>
> >>> HTH,
> >>>
> >>> ATTA
> >>>
> >>> On Tue, 20 Jul 2004 16:20:30 -0400, Erik Weber 
> >>> <[EMAIL PROTECTED]> wrote:
> >>>
> >>>
> >>>> How can I set a variable (I assume with c:set) that will 
> hold the 
> >>>> value
> >>>> of request.getServletPath, so that I can use it in el tags?
> >>>>
> >>>> Thanks,
> >>>> Erik
> >>>>
> >>>> 
> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>>
> >>>>
> >>>
> >>>
> >>> 
> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >>> For additional commands, e-mail: [EMAIL PROTECTED]
> >>>
> >>>
> >>>
> >>>
> >>
> >> 
> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [EMAIL PROTECTED]
> >> For additional commands, e-mail: [EMAIL PROTECTED]
> >>
> >
> >
> >
> > 
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to