Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

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

 
Greenhorn
Posts: 13
  • 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: 6896
163
  • 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: 13
  • 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: 23441
159
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.
 
Men call me Jim. Women look past me to this tiny ad:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic