Solved

How to get the URL text

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery ajax file upload not working 11 172
Need to view directory list in apache/tomcat 9 116
constructor overloading 2 83
Handle form fields in spring mvc controller 1 64
This article outlines the process to identify and resolve account lockout in an Active Directory environment.
When you have clients or friends from around the world, it becomes a challenge to arrange a meeting or effectively manage your time. This is where Outlook's capability to show 2 time zones in one calendar comes in handy.
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…

777 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