Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Servlets
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Jeanne Boyarsky
Ron McLeod
Paul Clapham
Liutauras Vilda
Sheriffs:
paul wheaton
Rob Spoor
Devaka Cooray
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Carey Brown
Frits Walraven
Tim Moores
Bartenders:
Mikalai Zaikin
Forum:
Servlets
url rewrite
Edward Chen
Ranch Hand
Posts: 798
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
if user inputs "/store/1234", I need redirect to "/store.do?id=1234". Could we do it in the jstl or
servlet
?
Thanks.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
The JSTL implies a
JSP
, and this would mean that you are using a JSP for something other than rendering a view. So, no.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
David Newton
Author
Posts: 12617
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Better to use a filter, or whatever URL rewriting extension your container/server supports.
Edward Chen
Ranch Hand
Posts: 798
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
David Newton wrote:
Better to use a filter,
how to write the filter ?
Thanks.
Bear Bibeault
Sheriff
Posts: 67746
173
I like...
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
Please show some initiative:
servlet filter
.
[
Asking smart questions
] [
About Bear
] [
Books by Bear
]
Edward Chen
Ranch Hand
Posts: 798
posted 13 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I think I found the result. Not use Spring interceptor, just put a filter before all spring.
like this
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { String requestUri = new UrlPathHelper().getRequestUri((HttpServletRequest) request); //abs/store/1234 String sevletPath = new UrlPathHelper().getServletPath((HttpServletRequest) request); //store String contextPath = new UrlPathHelper().getContextPath((HttpServletRequest) request);// abs if(requestUri.endsWith("store.do")==false && StringUtils.contains(requestUri, contextPath+"/store/")){ String storeId = requestUri.replaceAll(contextPath+"/store/", ""); String url = "store.do?cmd=view&storeId=" + storeId; ((HttpServletResponse)response).sendRedirect(url); } chain.doFilter(request, response); }
Thanks.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Confusion, HFSJ Page 385
Regular expression
command line parameter
who can tell what is the method parseInt( )?
SELECT * FROM studentrecords where [student id]='1234' doesnt returning the first row in mssql
More...