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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:44:00+00:00 2026-05-22T14:44:00+00:00

I have a fairly simple (I hope :P) question. I know that in good

  • 0

I have a fairly simple (I hope :P) question.

I know that in good old Java servlet code, I can derive the full request path of a request that comes into the web server like this:

String requestBaseUrl = 
    String.format("%s://%s:%s%s", request.getScheme(), request.getServerName(), 
            request.getServerPort(), request.getContextPath());

Now, doing the exact same thing in JSP is pretty straightforward to do. However, I now have to do this in Velocity 1.5 template. Specifically, I need to output that information as the ‘codebase’ attribute of a webstart applet I need to integrate into my web application.

I tried this, but the applet refused to start, instead throwing a FileNotFoundException 😛

<script src="http://www.java.com/js/deployJava.js"></script>
<script>
    var attributes = { code:'org.groundhog.MyApplet', width:360, height:280} ;
    var parameters = {
        jnlp_href: './webstart/myapplet.jnlp', <------------------ this
        bgColor: '#4f616d', mayscript: true
    };
    deployJava.runApplet(attributes, parameters, '1.6');

So I think that the most reliable way to do this is to derive and stick in the absolute URL where the application is running, and reference the applet’s jnlp file from there using the same logic as in my previous Java snippet.

Right now I’m shuffling through Velocity’s documentation. But, if anyone has had to deal with something similar, I’d be thankful for the equivalent idiom in Velocity.

I thank you for your time and help!

  • 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-22T14:44:01+00:00Added an answer on May 22, 2026 at 2:44 pm

    Well, after a short mind-clearing break, I came to the realization that essentially, Velocity is just a text template engine, and should have no business in doing code trickery in its views. Matt’s comment just confirmed my suspicions ;). Thank you!

    The simplest thing to do was to first derive the code base URL in my controller object, and then put that into the template’s model (say, a variable called “codeBaseUrl”), and just let Velocity render it. In short, a combination of the two approaches above.

    I offer my apologies, since I once again realize that 8 hours of sleep can solve nearly any problem. 😛

    Thank you for your time.

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

Sidebar

Related Questions

I have what I hope is a fairly simple question about using the value
I have a fairly simple const struct in some C code that simply holds
I have what should be a relatively simple question that I can't seem to
I have a fairly simple block of code. Sub Run(Name) on error resume next
I have a fairly simple python loop that calls a few functions, and writes
I have a fairly simple Linq query (simplified code): dim x = From Product
I have fairly simple problem but I can not think of the simple solution.
I have a fairly simple database that I inherited. For the purposes of this
I have a fairly simple console app that monitors an exchange mailbox, picks particular
I have a fairly simple problem. I'm trying to make a function that accepts

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.