• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

jsp vs servlet

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
Sheriff
Posts: 7000
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
How do they get the deer to cross at the signs? Or to read this tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic