1

I have a web portal. when a new user john doe registers with us, i wanted to create a new page for the user, like www.myportal.com/johndoe. How to do this in java jsp servlet. I have founded similar in facebook, you create a page and you will be able to find ...fb.com/page

Noufal
  • 41
  • 1
  • 2

1 Answers1

1

This isn't JSP on the fly. You never want to dynamically created JSPs based on user input. You want to store user input in the database. What you are looking for is url rewriting. You'll need a url rewriting filter for your servlet container (or put Apache HTTPD in front of your servlet container and use mod_rewrite). See Is there a url rewriting engine for Tomcat/Java? There's a filter that is not mentioned there, http://tuckey.org/urlrewrite/

Basically what you do is save the page the user is creating into a database. Setup rewriting rules to translate from server.com/pagename to something like server.com/handlepage.jsp?page=pagename. Then when the user goes to server.com/pagename its being handled internally by server.com/handlepage.jsp reading a page parameter. You then need to make your handling page pull the page from the database based on the page parameter.

Community
  • 1
  • 1
developerwjk
  • 8,619
  • 2
  • 17
  • 33