Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

url formating in web apps

 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like the URLs in my apps in a certain format.
Eg:
original urls
http://www.domain.com/list.jsp?country=uk&city=london&category=entertainment
required
http://www.domain.com/uk/london/entertainment/list.jsp
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Atul Sawant
Ranch Hand
Posts: 304
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The two urls you have given are quite different.
the first one uses the uk, london etc...as parameters whereas the the second url used them as an address where the the jsp page "list" is stored.

If you do not want to shows the parameters in the urls you can use "post" method instead of default "get" method.
[ March 25, 2007: Message edited by: Atul Savant ]
 
azhar bharat
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry. but i dint frame my question right, and hence the confusion.
My requirement is simple.Let me explain with an example.

Consider a property classifieds site. A user who wants to view the properties in london currently browsing through the site clicks on the corresponding link (first for country and then for city). The page url looks something like this : http://mydomain/list.jsp?country=uk&city=london.

Now what i intend to do. I want the visitor to view the same listing as above by typing the city and country in the url. i.e. http://mydomain/uk/london/

i hope i am clear this time.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two things you might want to read up on.

1.) The 'servlet-mapping' entries in the deployment descriptor.
The best place to go for information on these is the servlet spec.

2.) The 'front controller' or command pattern.
There are several conversations going on regarding this front controllers in this forum right now.


In a nutshell, you can create a servlet mapping that traps any requests with a given pattern (Struts filters on the ".do" extension) and routes the request to your front controller. From there, your front controller can analyze the URL (using the HttpServletRequest object) and forward the request to whatever command object you like.
 
Wayan Saryada
Ranch Hand
Posts: 105
IntelliJ IDE MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What about using something like URL rewriting library? I think it can help you to create a friendly url for user to access your website. Try something like http://tuckey.org/urlrewrite/.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic