jsp:include and servlets  
Author Message
Sascha Pohlmann





PostPosted: 2003-10-15 17:17:00 Top

java-programmer, jsp:include and servlets hello,

I have the following problem:

I would like to evacuate the logic from my jsp files in servlets. servlets
provide database contents prepared in HTML tables, the jsp files are
supposed to offer the graphic structure of the intranet application.

how does the path detail have to look?

thats my current include command:

<%@ include file="/proj/mdswpu/classes/ShowList" flush="true" %>

the whole thing is located in the directory webapps/Root/weave INF/classes.

do the path details cause problems or is it due to the servlet? is it no
matter whether doPost or doGet method is used?
the servlet delivers HTML via printwriter.

thank you for the help in advance ....


 
Kathy Benson





PostPosted: 2003-10-15 19:12:00 Top

java-programmer >> jsp:include and servlets

--------------030300030108070501060009--


Sascha,
It seems that your JSP is the one that is getting the initial request.
Turn this around - let your servlet get the initial request, which will
then route it to appropriate JSP file. Here is some code of how to send
request from a servlet to JSP.


String fileName = "/YourJSPFile.jsp"; //Make sure to start this with a slash
RequestDispatcher reqDisp =
servlet.getServletConfig().getServletContext().getRequestDispatcher(fileName);

if(reqDisp == null){
System.out.println("RequestDispatcher is null. Check if the file
name begin with a slash in the calling function.");
return;
}

reqDisp.forward(request, response);


Ideally, you should set aside one servlet that accepts all the calls
from your client. Check the FrontController pattern in the J2EE Design
Patterns book.

KB


--
------------------------------------------------------------------------
This email is certified to be Spam free by Spam Marshall

You don't pay to get spam, why pay to clean it?
Visit http://www.spammarshall.com to create an account for free
<http://www.spammarshall.com>

------------------------------------------------------------------------
Sascha Pohlmann wrote:

>hello,
>
>I have the following problem:
>
>I would like to evacuate the logic from my jsp files in servlets. servlets
>provide database contents prepared in HTML tables, the jsp files are
>supposed to offer the graphic structure of the intranet application.
>
>how does the path detail have to look?
>
>thats my current include command:
>
><%@ include file="/proj/mdswpu/classes/ShowList" flush="true" %>
>
>the whole thing is located in the directory webapps/Root/weave INF/classes.
>
>do the path details cause problems or is it due to the servlet? is it no
>matter whether doPost or doGet method is used?
>the servlet delivers HTML via printwriter.
>
>thank you for the help in advance ....
>
>
>
>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1">
<title></title>
</head>
<body>
<br>
Sascha,<br>
It seems that your JSP is the one that is getting the initial request. Turn
this around - let your servlet get the initial request, which will then route
it to appropriate JSP file. Here is some code of how to send request from
a servlet to JSP.<br>
<br>
<br>
String fileName = "/YourJSPFile.jsp"; //Make sure to start this with a slash<br>
RequestDispatcher reqDisp = servlet.getServletConfig().getServletContext().getRequestDispatcher(fileName);<br>
<br>
if(reqDisp == null){<br>
     System.out.println("RequestDispatcher is null. Check if the file name
begin with a slash in the calling function.");<br>
     return;<br>
}<br>
<br>
reqDisp.forward(request, response);<br>
<br>
<br>
Ideally, you should set aside one servlet that accepts all the calls from
your client. Check the FrontController pattern in the J2EE Design Patterns
book.<br>
<br>
KB<br>
<br>
<br>
<div class="moz-signature">-- <br>

<style type="text/css">
P {
font-family: Tahoma, Arial, Verdana;
font-size: 12px;
color: black;
}
H1 {}
H2 {}
H3 {}
HR{
line-height : 1;
text-align : left;
height : 1;
width : 80%;
color : #CC0000;
}
A {}
A:Visited {}
A:Active {}
A:Hover {}
BODY {
font-family: Tahoma, Arial, Verdana;
font-size: 12px;
color: black;
}
table {
font-family: Tahoma, Arial, Verdana;
font-size: 11px;
color: black;
}


</style>
<hr> This email is certified to be Spam free by Spam Marshall<br>

<p> You don't pay to get spam, why pay to clean it?<br>
Visit <a class="moz-txt-link-freetext" href="http://www.spammarshall.com">http://www.spammarshall.com</a> to create an account for free<br>
<a href="http://www.spammarshall.com" target="_blank"> <img
src="http://www.spammarshall.com/SpamMarshall/images/logo-c.gif"
border="0">
</a> </p>
<hr> </div>
Sascha Pohlmann wrote:<br>

<blockquote type="cite" cite="midbmj1tj$email***@***.com">

<pre wrap="">hello,

I have the following problem:

I would like to evacuate the logic from my jsp files in servlets. servlets
provide database contents prepared in HTML tables, the jsp files are
supposed to offer the graphic structure of the intranet application.

how does the path detail have to look?

thats my current include command:

<%@ include file="/proj/mdswpu/classes/ShowList" flush="true" %>

the whole thing is located in the directory webapps/Root/weave INF/classes.

do the path details cause problems or is it due to the servlet? is it no
matter whether doPost or doGet method is used?
the servlet delivers HTML via printwriter.

thank you for the help in advance ....


</pre>
</blockquote>
<br>
</body>
</html>