Win a copy of Zero to AI - A non-technical, hype-free guide to prospering in the AI era this week in the Artificial Intelligence and Machine Learning 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

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

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • 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: 6625
161
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • 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
  • 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: 22630
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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.
 
I knew that guy would be trouble! Thanks tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic