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

Implementing a virtual website with Servlets  RSS feed

 
Robert Drescher
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I am working on my CMS/Collab application for a project, in which users should be able to add pages derived from a template anywhere in the hierarchy.
As creating the pages as JSPs in the filesystem on the fly is not possible to my knowledge (and not really a desired way), I thought of using a servlet to implement virtual files.

So the servlet would be at the context path /cms/* and a call to a page in this hierarchy would look like
http://www.someserver.org/cms/teamsite/calendar/newevent

My first thought which was discarded quickly was to store the JSP source with the PathInfo in the database after copying it from the template... not possible and not a good practice

So the goal would be to have all the actual JSPs on one location (the templates), fill it with the data specified for /teamsite/calendar/newevent and return it's HTML output when the Servlet /cms is called.

How can I accomplish this?

Thank you for your help
Robert
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What you are looking for is a way through which the program can store a couple of templates, have the user provide some data (html perhaps) that should go into various areas in each template and finally display the same to the user ?

Just wanted to ensure that I got the question right before anyone can begin answering.
 
Robert Drescher
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exactly:
- Servlet processes request for an URL
- Loads JSP from a local template on the server (in a different directry which is not browsable)
- Fills template with data from SQL and
- returns the compiled output as response

The problem being: How to load a JSP on demand, modify it and compile it
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 37180
515
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Robert,
Welcome to JavaRanch!

Is the user supplying Java code in the content or just text/html? I suspect it is the later as that's how most content management systems work. If so, consider using a templating library such as Freemarker. (what this site uses incidently) Freemarker knows how to substitute the user parts in the correct place in the templates avoiding the need to be compiling with user content.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!