Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Personalized URL with Struts

 
Tuan Le
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to give my client a personalized URL like http://www.mydomain.com/FirstNameLastName

Is there anyway I can capture the Firstname and the Lastname from the query string using Struts framework?

Because this URL does not have a filename e.g. .htm or .jsp and this does not hit my custom 404 as well.

Is this possible? I have seen some personalized e-cards like this.

One option is to create an HTML file for each customer (let's say we have 1000 customers) and inside HTML body have it redirect to a Struts action to process the customer information based on their unique first name and last name combination. But this option is not attractive for our case because of 2 reasons:

1) we have to generate 1000 HTML files with customer name
2) The URL has a file extension .html at the end.

Thanks in advance for your help!
Tuan
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do the users have to log in when going to their page?
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can access the URL information using the following methods in the javax.servlet.http.HttpServletRequest interface:
getContextPath()
getPathInfo()
getQueryString()
getRequestURL()
getRequestURI()
getServletPath()

Just write a servlet that uses the above methods to access whatever information you want from the URL and map that to "/*" in your web.xml.
 
Tuan Le
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your time and help!

Tuan
 
Tuan Le
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PROBLEM:
Please help with my servlet mapping issue. It's calling my redirector class repeately and the redirector does not work.

REQUIREMENTS:
I want to give my client a personalized URL like http://www.mydomain.com/myWebApp/FirstName_LastName (NOTE: no file extension).

When the user enters that URL above, it would be processed by a servlet
RequestProfileRedirectorServlet, which is defined in web.xml and it has a servlet mapping to "/*" (NOTE: see servlet code and web.xml config below).

The main task for the RequestProfileRedirectorServlet is to get the request path info (NOTE: in my case it's /FirstName_LastName), build a redirect URL, and redirect it to a Struts welcome action (welcome.do) to query the user profile from the database and display the user profile in a welcome view. An example of a redirect URL would be

http://www.mydomain.com/myWebApp/welcome.do?cid=FirstName_LastName

SOURCE:


Do you know what I'm missing?

Thanks,
Tuan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic