Solved

How to get the URL text

Posted on 2002-07-22
5
151 Views
Last Modified: 2010-04-01
Hi, all

When I type (server name)/home.jsp, I need to show a popup message: This is our home. How can I get the URL text?
For example:
If URL = "(server name)/home.jsp"
  alert ("This is our home");

Thanks
0
Comment
Question by:jl2001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 7170753
Better to just have your jsp include the js to call your alert when the window is loaded (onLoad) if the url matches.
0
 
LVL 6

Expert Comment

by:kotan
ID: 7170925
<%
  String URL = request.getRequestURI();
%>
0
 
LVL 19

Accepted Solution

by:
cheekycj earned 50 total points
ID: 7174482
your specific code can be like this:

<% if (request.getServerName().equals("www.yoursite.com") && request.getRequestedURI().equals("/home.jsp")) { %>
<script>
  alert("Welcome to the Home Page!");
</script>
<% } %>

or do it purely based on the URI as indicated above:

<% if (request.getRequestedURI().equals("/home.jsp")) { %>
<script>
  alert("Welcome to the Home Page!");
</script>
<% } %>


or you can do it in JavaScript as indicated above:

<script>
 if (location.href == "http://www.yoursite.com/home.jsp")
    alert("Welcome to the Home Page!");
</script>

HTH,
CJ
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 9561053
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

"Accept cheekycj's comment as answer."
 
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Kuldeepchaturvedi
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Learn why we support net neutrality and why the topic is important to all internet users.
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question