Thanks, Olu!
OK, everything's working now (kinda)
My problem is that my servlet (sitting in the /classes subdir & accessed via
'http://localhost:8080/servlet/ServletName') cannot get to any servlet in the
'localhost:8080/examples/servlet' context, even though the samples are all there
and can be invoked directly through the browser. Nor, for that matter, can it
get to any of the sample JSP's ('/localhost/examples/jsp/...').
The servlet I create in '/classes' can only access other servlets in the same
subdir, or JSP's lying anywhere below '/webpages'
Has anybody else come across this problem?
I have NOT modified any of the .CFG or .PROPERTIES files
My environment is NT4/JDK2
- Neville
"Emuleomo, Olu (PME)" <[EMAIL PROTECTED]> on 06/03/99 11:10:26 AM
To: Neville Soares/Whittman-Hart LP@W-H
cc:
Subject: RE: R: Model II Problem
I'm using java2.
My docbase is ./ (ie the current dir)
That's where my jsp files reside!
import java.io.*;
import java.util.*;
import java.sql.*;
import java.text.*;
import javax.servlet.*;
import javax.servlet.http.*;
import beans.*;
public
class ExamSearchForFile extends ExamServlet
{
public void doGet (HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException
{
ExamSearchForFile_Bean bean = new ExamSearchForFile_Bean();
bean.load_menu_from_db();
req.setAttribute("dataBean", bean); //lifespan = page
getServletContext().getRequestDispatcher("/ExamSearchForFile.jsp")
.forward(req, res);
}
public String getServletInfo()
{
return ("Now mainly a redirection facility to
ExamSearchForFile.jsp");
}
}
> -----Original Message-----
> From: [EMAIL PROTECTED] [SMTP:[EMAIL PROTECTED]]
> Sent: Thursday, June 03, 1999 10:41 AM
> To: Olu Emuleomo
> Cc: [EMAIL PROTECTED]
> Subject: Re: R: Model II Problem
>
>
>
> Olu,
>
> I'm using the same HttpServer, and I always get a Error:404 (If I forward
> to a
> servlet) or Error 400 (If I forward to an HTML file)
>
> Could you send me some sample code as well as the location of the JSP
> called by
> your servlet?
>
> - Neville
>
>
>
>
> Olu Emuleomo <[EMAIL PROTECTED]> on 06/03/99 10:42:40 AM
>
> To: Neville Soares/Whittman-Hart LP@W-H
> cc: [EMAIL PROTECTED]
> Subject: Re: R: Model II Problem
>
>
>
>
> I had no problem with it! But I am running the mini HttpServer that comes
> with
> the jsp1.0 distribution.
>
>
> --Olu E.
>
> Neville Soares wrote:
> >
> > 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".
>
>
>
===========================================================================
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".