0

Is there a way to do:

java.net.InetAddress.getLocalHost().getHostName()

without using JSP Scriptlets? Looking for a more conventional solution, probably using JSTL capabilities to achieve this.

Take note that ${pageContext.request.*} jstl function doesn't give me the output I want. I want the computer host name.

I tried a JavaScript but it didn't work, no idea as of why:

<script>document.write(java.net.InetAddress.getLocalHost().getHostName())</script>
link_boy
  • 1,025
  • 4
  • 12
  • 23

2 Answers2

1

What output does $pageContext.request.* give you and how is it not what you want?

Is ${pageContext.request.localName} not what you want?

taz
  • 1,506
  • 3
  • 15
  • 26
  • `java.net.InetAddress.getLocalHost().getHostName()` gives me for example "link_boy" host string (computer host name) when I'm running the app with the following url "http://localhost/app" `pageContext.request.localName` gives me "localhost" as host name – link_boy Dec 13 '11 at 19:45
0

InetAddress doesn't have a public constructor which stops it from accessing it using jsp:useBean.

If you really want to get rid of scriplets,

  • you can pass the value from the backend as a response
  • write a custom class to get the value and access the class using jsp:useBean
arvind_cool
  • 293
  • 1
  • 13