Solved

How to get the URL text

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

Facebook has became the #1 social media platform. People share many funny videos there, yet you don't know how to download them? Now you can download Videos from Facebook in just 3 simple steps.
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

749 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