Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

reading servlet config from a bean  RSS feed

 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have several places in the jsp files of a web app where I want to change the action attribute of a form depending on whether I'm running on my development machine or the production box
right now I have a bean with a function I can call from the jsp to return either "localhost" or "www.foo.com" depending on which I've tweaked the code to return
I'd like to automate this since I invariably forget to do it when I deploy the app to the production box
I guess I should do it anyway just to make the app portable
so, the question
how can a bean which simply extends "object" determine the URL of the server it's on?
I know my terminology isn't right there, it's not the "server"
a "server" can host many domains each with many web apps
what's the correct term, "servlet context"?
have I made it clear what I want to do?

TIA
Dave
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually the forms example is a bad one
try this
the app uses the google maps tool they give away
it requires a "key" that varies depending on the URL you're serving it from
I want to have the bean return the proper key and it needs to know the URL it's being served from to do it

Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66142
141
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps java.net.InetAddress.getLocalHost().getHostName() is what you are looking for.
 
Dave Robbins
Ranch Hand
Posts: 131
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that solves my problem
thanks

Dave
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!