Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8562997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:51:27+00:00 2026-06-11T16:51:27+00:00

I am using Apache Tomcat with Velocity and VelocityViewServlet. I have created a custom

  • 0

I am using Apache Tomcat with Velocity and VelocityViewServlet. I have created a custom tool with refference to ViewContext. It all works well.

The question is: what is best way to locate/load template and procces it with suplied parameters?

I have already absolute path to the file obtained via

((ViewContext)context).getRequest().getSession().getServletContext().getRealPath("/")
  • Do I have to instantiate VelocityEngine? I suppose there is no global maintained by Velocity (VelocityViewServlet)
  • Which (and how) of Velocity loaders is best to use?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:51:28+00:00Added an answer on June 11, 2026 at 4:51 pm

    Several points here:

    • The VelocityViewServlet will instantiate itself a VelocityEngine. It’s not global, it’s one engine per ServletContext.

    • The VelocityViewSerlet will locate itself the template that corresponds to the request URI using its default loader (WebappLoader), so you don’t have to do it yourself either.

    • The Velocity context your template will be evaluated with, will already be populated with all standard tools (for tools 2.0), among which $params which allows you to inspect HTTP parameters.

    • I don’t understand “a custom tool with refference to ViewContext”: instead of using the ViewContext, you should add to your custom tool all the appropriate setters you need among the properties listed here (for instance, if you need access to the request, then you’ll declare a “public setRequest(HttpServletRequest request)” method). Remember that from a bottom-up perspective, your tool must be only reachable via a key that you choose for it in your tools configuration file, and should not be aware of Velocity.

    • I advise you to use VelocityTools 2.0, which is a more mature library than the 1.x.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using apache tomcat as a web server. I have deployed webservices on
We have an application deployed on tomcat. To access application we are using apache
I am using Tomcat 6 and have some questions about Apache mod_jk as follows.
We have a large web app installation, using Apache/Tomcat/Jasper and jboss. In development environment,
i have developed an application using jsf 1.2. it worked fine with apache tomcat
I've created a facebook application using flex. i tried server side both with apache-tomcat
I am using Apache Tomcat 6.0.18, I am running on Windows XP I have
I am using Apache tomcat 7.02 as a server.I created an application using sphinx4
Hi i am using apache tomcat. i have a jsp file for entering user
I have a simple web service deployed on tomcat using Apache Axis. If i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.