Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating a Profile Page/Link  RSS feed

 
razi mohd
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am developing a webapplication, and as a part of it, i need to have individual links for the users profiles as shown below..
if the users has given the name as razzyy, then i want this user to have his profile at http:\\www.applicationname.com\razzyy

currently, i am thinking of creating a directory for each user with a common jsp file (welcome file) inside it.. this jsp will take 'razzy' out from the link http:\\www.applicationname.com\razzyy in order to identify whoes data is to be fetched and displayed..
am I right in this approach..?? or is there some other approach which will be followed in order to acheive this..? please suggest.


Thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be a very poor approach in my opinion. The info should be kept in a database, not on the file system, and a single JSP should be able to serve anyone's profile with dynamic data from the DB.
 
razi mohd
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I understand, but can you please tel me the right approach for this.
as the link here will be different for each user..
say for me i will have the link http:\\www.applicationname.com\razi
and yours could be like http:\\www.applicationname.com\bear

how can we redirect both these links to a single JSP..!??
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66141
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can map a servlet to capture all the requests; for example with path /profile/*. That way, URLs such as /profile/bear and profile/fred would route to the servlet. Then in the servlet obtain the name from the path info.
 
razi mohd
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this solution creates a problem wen it comes to my requirement..
this will work for www.abc.com/profiles/bear
but not for www.abc.com/bear.. as, all the requests even the ones i dont want to will be redirected to a single servlet..

i have one more idea.. wat if i add the error handling in web.xml for 404 code.. all the pages which doesnt exist(even the profile links ex: www.abc.com/bear) will go to a single jsp and there i'l identify wheather the url should be taken as valid or actually it is invalid..
wil this ok..?! or any other better idea.. ??
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!