Click to See Complete Forum and Search --> : [RESOLVED] Pull content from array depending on referer


absolutmgd13
06-16-2009, 01:55 PM
I want to write something to do the following.

I have a list of referrers (yahoo.com, google.com, ect.)

I have a page that displays the referrer now:
<%@page import="java.net.InetAddress;"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>

<%
out.println(request.getHeader("Referer"));
%>


What i want to happen is, if i come from yahoo i want to import/load content, either an external html or maybe content from an array into the html page displaying the referrer.

i try to get to my page from yahoo, but denied access so you see the referrer, then a imported or loaded message saying why you cant come from yahoo..

same with the rest of the referrers..

being new to java i tried to write this as simply as possible to give you an idea of what im trying to do


<%
out.println(request.getHeader("Referer") + "<br /><br />");

String[] appError=new String[3];
appError[1] = "no from yahoo because...";
appError[2] = "no from google because...";
appError[3] = "no from msn because...";

if (Referer != [www.yahoo.com]) {
out.println(appError[1]);

}
if (Referer != [www.google.com]) {
out.println(appError[2]);

}
if (Referer != [www.msn.com]) {
out.println(appError[3]);

}
%>


any help would be greatly appreciated!

I've also tried this

<%@page import="java.net.InetAddress;"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%
out.println(request.getHeader("Referer") + "<br /><br />");


String[] appError=new String[3];
appError[1] = "no from yahoo because...";
appError[2] = "no from google because...";
appError[3] = "no from msn because...";
%>
<HTML>
<HEAD>
</HEAD>

<BODY>
<%
int i=Referer;
for(i=Referer;i<appError.length;i++)
{
out.print("app Error is: " + appError[i] + "<br/>");
}
%>
</BODY>
</HTML>

chazzy
06-16-2009, 05:40 PM
should get you going


Referer != "[www.yahoo.com]"

absolutmgd13
06-17-2009, 11:32 AM
haha.. could you elaborate?.. this is the first week of even seeing this type of code.

absolutmgd13
06-17-2009, 12:01 PM
<html>
<body>
<script type="text/javascript">
var x=Referer;
var mycontent = new Array();
mycontent[0]='no from yahoo because..'
mycontent[1]='no from google because..'
mycontent[2]='no from msn because..'

if (i=0;i<mycontent.length;i++)
{
document.write(mycontent[i]);
}


for (Referer != "[www.yahoo.com]") {
document.write(amycontent[0]);
}

for (Referer != "[www.google.com]") {
document.write(mycontent[1]);
}

for (Referer != "[www.msn.com]") {
document.write(mycontent[2]);
}

</script>
</body>
</html>

absolutmgd13
06-17-2009, 12:20 PM
i think javascript may be easier for me.. ill give that a shot before i start getting into jsp