Enrico,
No, I haven't been able to resolve it...in fact my conclusion is that
RequestDispatcher.forward() does NOT work at all in JSP1.0 Ref Impl
I downloaded JWS2.0 beta 2 and forward() does work from Servlet to Servlet, but
not when invoking a JSP
Has anybody else been able to get Model II to work with JSP1.0?
- Neville
[EMAIL PROTECTED] on 06/03/99 09:25:10 AM
To: Neville Soares/Whittman-Hart LP@W-H, [EMAIL PROTECTED]
cc:
Subject: R: Model II Problem
Hi,
I have noticed that you encountered my same problem.
Have you found a solution?
Can someone help me?
Thanks in advance.
Enrico
_______________________________________________________
Friends,
I'm running the JSP1.0 ref impl on NT4, and regular JSP's work fine.
I decided to try the 'Model II' approach and, lo & behold, it doesn't work.
Here's the steps:
1. I have an HTML form that submits a text field to a servlet
2. Here's the servlet: (it compiles fine)
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import hello.*;
public class HelloServlet extends HttpServlet {
public void init(ServletConfig config) throws ServletException
{super.init(config);}
public void doPost(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
//Get the session object
HttpSession session = request.getSession(true);
//create the 'there' class
there thing = new there() ;
String text = "{" + request.getParameterValues("sample")[0] + "}" ;
thing.setSample (text);
session.putValue("thing", thing);
getServletContext().getRequestDispatcher("/examples/jsp/hello/hello.jsp").fo
rward
(request, response);
}
}
3. Here's the bean:
package hello;
public class there {
private String sample = "<No Data>";
public there() { }
public String getSample() {return "You entered:<b>" + sample + "</b>";}
public void setSample(String newSample) {sample = newSample; }
}
4. Here's the JSP:
<jsp:useBean id="foo" scope="session" class="hello.there" />
<jsp:setProperty name="foo" property="*" />
<html>
<head>
<title>Hello</title>
</head>
<body>
<jsp:getProperty name="foo" property="Sample"/>
</body>
</html>
5. This is the result of submitting the form to the Servlet:
Error: 404
No detailed message
What is wrong with my code?
6. I then modified the servlet's doPost() to return an HTML page with a link
to
the JSP, as in:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//Get the session object
HttpSession session = request.getSession(true);
//create the 'there' class
there thing = new there() ;
String text = "{" + request.getParameterValues("sample")[0] + "}" ;
thing.setSample (text);
session.putValue("thing", thing);
//getServletContext().getRequestDispatcher("/examples/jsp/hello/hello.jsp").
forward
(request, response);
PrintWriter out = response.getWriter();
out.println("<html><head><title>Hello</title></head><body>" );
out.println("You Said:<b>" + text + "</b>" );
out.println("<a href='/examples/jsp/hello/hello.jsp'>Go to JSP</a>" );
out.println("</body></html>" );
}
7. The JSP finds nothing in the bean:
You entered:
8. To determine if the servlet was, in fact, placing the bean into the
session,
I modified doPost() again to return a link to another servlet:
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
//Get the session object
HttpSession session = request.getSession(true);
//create the 'there' class
there thing = new there() ;
String text = "{" + request.getParameterValues("sample")[0] + "}" ;
thing.setSample (text);
session.putValue("thing", thing);
//getServletContext().getRequestDispatcher("/examples/jsp/hello/hello.jsp").
forward
(request, response);
PrintWriter out = response.getWriter();
out.println("<html><head><title>Hello</title></head><body>" );
out.println("You Said:<b>" + text + "</b>" );
out.println("<a href='/examples/servlet/TargetServlet'>Go to Target
Servlet</a>" );
out.println("</body></html>" );
}
9, The doGet() of the Target servlet looks like:
public void doGet(HttpServletRequest request, HttpServletResponse
response)
throws ServletException, IOException {
//Get the session object
HttpSession session = request.getSession(true);
//create the 'there' class
there thing = (there) session.getValue("thing") ;
String text = thing.getSample ();
PrintWriter out = response.getWriter();
out.println("<html><head><title>Target</title></head><body>" );
out.println("I found:<b><font color=red>" + text + "</font></b> in the
session" );
out.println("</body></html>" );
}
10. This works fine:
I found:You entered:{Yeah!} in the session
So, I have 2 questions:
1. Why doesn't my Servlet->JSP code work?
2. Why do I have to restart JSP1.0 every time I change the servlet? Isn't
the
servlet engine supposed to reload a changed servlet?
Thanks in advance.
- Neville
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".