This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Servlets and the fly likes jsp vs servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "jsp vs servlet" Watch "jsp vs servlet" New topic
Author

jsp vs servlet

mary sarami
Greenhorn

Joined: Feb 11, 2001
Posts: 25
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: 6920
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?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp vs servlet
 
Similar Threads
static and dynamic includes HELP PLEASE
calling a java Script file into the Jsp
Jsp 1.0 problem
jsp includes
Dynamic HTML page titles using jsp