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 7056465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:52:14+00:00 2026-05-28T03:52:14+00:00

I’m trying to format our emails by using HTML-formatted templates on Google App Engine

  • 0

I’m trying to format our emails by using HTML-formatted templates on Google App Engine (using Java), but for the life of me I cannot find a decent tutorial for how to set this up.

I’ve tried looking at StringTemplate, but I cannot find any examples where a stand-alone template is loaded from a servlet’s context and used as a formatter.

Can anyone help? I’m open to any suggestions, such as Velocity or FreeMarker, so long as they run on GAE.

Thanks

  • 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-05-28T03:52:14+00:00Added an answer on May 28, 2026 at 3:52 am

    Figured out how to do it.

    The documentation for StringTemplate can be very confusing. The latest version (version 4) has different classes than previous versions (ST instead of StringTemplate, STGroup instead of StringTemplateGroup, etc)

    It also has an external dependency on ‘antlr’. Per these instructions (link contains links to jars needed), put the ‘antlr’ and ‘SimpleTemplate’ jars in the WEB-INF/lib directory on the server.

    Version 2 introduced template ‘groups’, which as far as I can tell, are required for loading a template from a file on a web server.

    So to get it working, I had to define a template group file, with the following content, named emailTemplate.stg

    html_format(keyToReplace1, keyToReplace2) ::= <<
    <html>
    <body>
      <div>
        This is $keyToReplace1$
        <br/>
        This is $keyToReplace2$
      </div>
    </body>
    </html>
    >>
    

    I then had to ensure this file was accessible by my code via a relative URL. This is easily testable by going to the URL in the browser, such as at: localhost:8888/templates/emailTemplate.stg

    Then, to use this template, I used the following code:

    STGroup g = new STGroupFile("templates/emailTemplate.stg", '$', '$');
    ST emailTemplate = g.getInstanceOf("html_format");
    emailTemplate.add("keyToReplace1", "value for the first key");
    emailTemplate.add("keyToReplace2", "value for the second key");
    String result = emailTemplate.render();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has

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.