[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to get the URL text

Posted on 2002-07-22
5
Medium Priority
?
155 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
4 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 200 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Applications for our next round of the Experts Exchange Scholarship Contest are starting to roll in. It made us wonder what our past winners are up to these days. Here's a look at what four winners experienced with the contest and what they're doing…
Strategic internal linking is often considered an SEO power technique, especially for content marketing. Do you need to hire an SEO agency to optimize you internal linking? No, this article will help you understand the basics of internal linking and…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

873 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