Basically i have a web app which is java based and spring based, the idea is some one can join the web app, then a unique web page will be assigned to this person. So several users would have a unique web page each. And anybody can view the page.
Now i had thought of just ceating the web page in the web app directory on the fly, Then displaying the url to the person so they can access the page.
But one problem is i cant seem to get web app dir path when the app is deployed to say Jetty.
Will just return c:/Jboss/bin, which to me looks like the wrong place to store web pages as they would not be deployed to the app. Anybody know how to get the webapp dir once a app is deployed without being in a servlet or a jsp.
Another line of thought was that i could store the unique pages in like a root dir such as docs and settings, then try and catch a certain web request and map it to a web page stored offline, so the page is called via the web, my app looks at the request goes to an offline file or database call and gets the appropiate info and dishes it back. Would this be possible, if so can some body point me to some good documentation on it.
best Mark
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35223
7
posted
0
Do you really need physical pages for each user? The usual approach would be to store all data that is needed to generate the user-specific page in a database, and then to assemble the page dynamically using that information. Then the URL for each user's page would include that user's ID somehow, e.g. http://server.com/app/userPage?id=12345 or http://server.com/app/userPage/12345
As to mapping HTTP requests and physical file locations inside of the web app, check out HttpServletRequest.getContextPath and ServletContext.getRealPath.
Placing user generated content under the WEB-INF folder is a bad idea. What happens if you need to redeploy your application?
Mark Hughes
Ranch Hand
Joined: Jul 14, 2006
Posts: 145
posted
0
Hi Ulf, Nope i dont think i need physical pages for each user, just trying to understand how i might do it and the best approach. I think your suggested solution would work best, and its something i thought about but not entirely sure how to go about doing it or looking for examples.
Hi Gregg, Yea your right there, constant redeploying would be bad idea especially if the pages were to change alot.
So i think the best way to do it is to generate the url and page dynamically on a fly, I guess a solution would be to map a servlet to a certain context such as servletName* and then do some parsing in the servlet to detect the end of the url typed and perform work on it. Would ye know of any examples of this i could look at, or the correct term on this so i can research it more.
You just pull the ID out of the request parameters and based on that ID gather up all the user data and forward to a JSP. It might look something like:
Are you using SpringMVC for anything or are you using plain servlets? If the latter, I should move this to the Servlet forum as this isn't about Spring.
Mark Hughes
Ranch Hand
Joined: Jul 14, 2006
Posts: 145
posted
0
Hey Gregg,
Yea thats making sense to me now, cool thanks. Yea at this stage is just servlets. Thanks again.