I put together the below jsp to determine which ip address was coming to the site, depending on the ip address a different set of "headers" are included in the page. How best would I change this into a servlet? Any help would be appreciated. Thank you.
<% String agent = request.getRemoteAddr(); // this is the default. It is only modified if the // correct chars are in the Remote Address // top3 returns content for unknown clients String incFile = "head3.html"; if ( agent != null ) { if ( agent.length() < 1 ) { // return content for Internet Users incFile = "head1.html"; } else if ( agent.startsWith (("127.0.0.1") | | (agent.startsWith("192.103.")))) { //return content for GNET browsers incFile = "head2.html"; } } %> <%-- dynamically include the file --%> <jsp:include page="<%= incFile %>" flush="true"></jsp:include>
Frank Carver
Sheriff
Joined: Jan 07, 1999
Posts: 6913
posted
0
The simplest way to change it into a servlet is to let the JSP container do it for you! Part of the process of compiling JSPs is to generate a servlet, but how you find the servlet it has generated depends on the servlet container. Why do you need to do this?