Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

jsp vs servlet

 
mary sarami
Greenhorn
Posts: 25
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6920
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic