• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Tomcat - How to set which velocity file should be the default for a URL?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where do I configure which VM file should be the default for a specific URL?

For Example:

for url `mysite.com/messages` I have the following files in views but I want to load the `inbox.vm` as the default vm for that url.

   views/messages/compose.vm
   views/messages/messagedisplay.vm
   views/messages/inbox.vm

for url `mysite.com/status` I have the following files in views but I want to load the `list.vm` as the default vm for that url.

   views/status/list.vm
   views/status/share.vm
   views/status/search.vm


 
Saloon Keeper
Posts: 7101
165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Isn't there logic somewhere in your code to decide which template to use for which URL? IIRC, Velocity is a general-purpose templating engine that has no knowledge of servlets.

Edit: I see there's something called the VelocityViewServlet, but from a quick look it's not clear how it maps requests to templates. Do you need to override the getTemplate method? Or maybe the handleRequest method, if I understand #5 in https://www.baeldung.com/apache-velocity correctly.

Anyway, how are you handling this in your code?
 
John Herrington
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It might be somewhere.. That's what I'm trying to figure out. I didn't setup any of this and now I have it to figure out.

 
Saloon Keeper
Posts: 24325
167
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check to see if the VelocityViewServlet is handling those URLs. It would be setup like this: https://velocity.apache.org/tools/devel/view-servlet.html

If that isn't present in your web.xml, then look in the webapp's servlet source codes for an explicit call to Velocity and work backwards from the servlet's web.xml definition (or equivalent annotation). Also check to see if a JSP is running Velocity. Which I suspect is a messy thing to do, but that doesn't deter some people.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic