0

I'm creating a J2EE web application in which I'm giving my users an ability to create a page (Yeah almost like Facebook ;) ). These pages will be created dynamically i.e. user will be asked some details like page name, description etc, moreover the user will be asked an unique URL Eg: www.mywebsite.com/user_unique_url.jsp for the page and after submitting all the details the page will be created. What I'm looking for is that a mechanism through which when the user has submitted all the details a page would be created and with the URL as given by the user. I'm open to other suggestions which helps me as how to create such page. Thanks in advance.

Saumil
  • 2,521
  • 5
  • 32
  • 54
  • 2
    So by "dynamically" creating web pages you mean storing JSP files with user content on the server's file system? Not a good idea, because of numerous reasons, security, scalability, performance, just to name a few. – Adam Siemion Jan 10 '14 at 17:45
  • @AdamSiemion yeah thats what I meant. Can you suggest me any other way? – Saumil Jan 10 '14 at 17:46
  • 1
    Use any Java web framework (Play!, Grails, GWT) that can serve dynamic content from a persistence layer (e.g. database). – Adam Siemion Jan 10 '14 at 17:52
  • @AdamSiemion Thanks, can Spring be of any help? – Saumil Jan 10 '14 at 17:54

2 Answers2

3

Creating a new JSP file for every page is not a good idea. You can just create one JSP file (template), and for every user, you can put the right information in the right place.

For example www.yourwebsite.com/userpageID is the URL of the page. Get all the page information with a simple SELECT query (ex : SELECT * FROM pages WHERE id = userpageID ). And in your JSP file, you put information selected by the query.

1

I'm not a java developer but you're looking for routes.

There will be probably a configuration file where you can redirect every request to another address.

For example; Requests on http://local.hots/what_you_want

are redirected to http://local.hots/page.jsp?page=what_you_want

rafaelsoma
  • 96
  • 1
  • 6
  • The point is you shouldn't create pages dynamically. You should make one page ahead of time and send it a parameter. Then use some kind of URL rewriting module to make the parameter part of the URL. – developerwjk Jan 10 '14 at 19:31
  • See http://stackoverflow.com/questions/950497/is-there-a-url-rewriting-engine-for-tomcat-java on URL rewriting – developerwjk Jan 10 '14 at 19:42