Bosch Ricardo wrote:

> What exactly is the code a  JSP page compiles when you put in a usebean tag.
> Like as if I was trying to use/create  a session bean in  a servlet.  I'd also
> like to come up with some way to redirect a user who directly tries to go to
> page that uses a bean , when they should be coming from a servlet.
>
> thanks
> rick
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

Well you can find the place where your JSP enginne puts the .java file that it
creates to compile the resulting servlet.
in JRun this location is
<install-path>/jrun/jsm-default/services/jseweb/servlets/jsp/Docs/

and for your info here is one of my test JSP's and the .java file generated from
it. Note that it is using JRun so if you use a different engine your .java file
will be different.

Karl

page hellouser.jsp:-

<%@ page import="com.kms.beans.NameHandler" %>

<jsp:useBean id="mybean" scope="page" class="com.kms.beans.NameHandler"
type="com.kms.beans.NameHandler" >
<jsp:setProperty name="mybean" property="*" />
</jsp:useBean>


<html>
<head><title>Hello, User</title></head>
<body bgcolor="#ffffff" background="background.gif">

 <%@ include file="dukebanner.html" %>
        <table border="0" width="700">
        <tr>
        <td width="150"> &nbsp; </td>
        <td width="550">
        <h1>My name is Bart. What's yours?</h1>
        </td>
        </tr>
        <tr>
        <td width="150" &nbsp; </td>
        <td width="550">
        <form method="get">
        <input type="text" name="username" size="25">
        <br>
        <input type="submit" value="Submit">
        <input type="reset" value="Reset">
        </td>
        </tr>
        </form>
        </table>

        <%
         if ( request.getParameter("username") != null ) {
 %>

 <%@ include file="response.jsp" %>

 <%
         }
 %>

</body>
</html>

the heollouser.java file:-
// Generated by JRun, do not edit

package jsp.Docs;

import java.io.*;
import java.util.*;
import java.net.*;
import java.beans.*;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;

import com.livesoftware.jsp.*;
import com.livesoftware.scripting.*;

import com.kms.beans.NameHandler;



public class hellouser extends HttpJSPServlet implements JRunJspPage
{

    public void _jspService(HttpServletRequest request, HttpServletResponse
response) throws ServletException, IOException
    {
        ServletConfig config = getServletConfig();
        ServletContext application = config.getServletContext();

 Object page = (Object) this;
        PageContext pageContext =
JspFactory.getDefaultFactory().getPageContext(this, request, response,  null,
true,8192, true);
        JspWriter out = pageContext.getOut();

        HttpSession session = request.getSession(true);
        response.setContentType("text/html");
        Object __mybean_was_created[] = new Object[1];
        com.kms.beans.NameHandler mybean = (com.kms.beans.NameHandler)
JSPRuntime.instantiateBean("mybean", "com.kms.beans.NameHandler", "page",
__mybean_was_created, pageContext, request, session, application);
        if(((Boolean) __mybean_was_created[0]).booleanValue()) {
        JSPRuntime.setBeanProperty(mybean, "mybean", "*", request);
        }
        out.print("\n\n\n<html>\n<head><title>Hello, User</title></head>\n<body
bgcolor=\"#ffffff\" background=\"background.gif\">\n \n <table border=\"0\"
width=\"400\" cellspacing=\"0\" cellpadding=\"0\">\n\n<tr>\n<td height=\"150\"
width=\"150\"> &nbsp; </td>\n<td width=\"250\"> &nbsp; </td>\n</tr>\n\n<tr>\n<td
width=\"150\"> &nbsp; </td>\n<td align=\"right\" width=\"250\"> \n\n<img
src=\"../Arts/BartMoon.gif\"> </td>\n</tr>\n\n </table>\n<br>");
            out.print(" \n        <table border=\"0\" width=\"700\">\n
<tr>\n        <td width=\"150\"> &nbsp; </td>\n        <td width=\"550\">
\n        <h1>My name is Bart. What's yours?</h1>\n        </td>\n
</tr>\n        <tr>\n        <td width=\"150\" &nbsp; </td>\n        <td
width=\"550\">\n        <form method=\"get\">\n        <input type=\"text\"
name=\"username\" size=\"25\">\n        <br>\n        <input type=\"submit\"
value=\"Submit\">\n        <input type=\"reset\" value=\"Reset\">\n
</td>\n        </tr>\n        </form>\n        </table>\n\n        ");
    if ( request.getParameter("username") != null ) {
         out.print("\n \n <table border=\"0\" width=\"700\">\n<tr>\n<td
width=\"150\"> &nbsp; </td>\n\n<td width=\"550\">\n\n<h1>Hello, ");
            out.print(JSPRuntime.getBeanProperty(mybean, "mybean", "username"));
        out.print("!\n</h1>\n \n</td>\n</tr>\n</table>\n\n\n");
    }
         out.print("\n\n</body>\n</html>\n\n\n");
            out.flush();
    }

    private static final String[] __dependencies__ = {"dukebanner.html",
"response.jsp", ""};

    public String[] __getDependencies()
    {
        return __dependencies__;
    }

}

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to