Solved

How to get the URL text

Posted on 2002-07-22
5
145 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

HOW TO: Install and Configure VMware vSphere Hypervisor 6.5 (ESXi 6.5), Step by Step Tutorial with screenshots. From Download, Checking Media, to Completed Installation.
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now