Servlet -- HttpSession -- JSP , Why ClassCastException

When I put an object in the HttpSession in a servlet and try to get it
(and casting) , in a JSP within the same session, i get ClassCastException,
any body knows the problem?
thanks,
ali.

What WL version you runing? Is this object in your CLASSPATH?
Gene
"ali" <[email protected]> wrote in message news:3a8c5e32$[email protected]..
When I put an object in the HttpSession in a servlet and try to get it
(and casting) , in a JSP within the same session, i get ClassCastException,
any body knows the problem?
thanks,
ali.

Similar Messages

  • Servlets and Workspaces (AND ClassCastExceptions)

     

              I have a similiar situation but am not getting a ClassCastException but rather a
              NullPointerException when I try
              to use a contained object in my stored object.
              I do this in the server:
              WorkspaceServicesDef workspaceServices = services.workspace();
              WorkspaceDef defaultWS = workspaceServices.getWorkspace();
              WorkspaceDef dataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
              WorkspaceDef.CREATE,
              WorkspaceDef.SCOPE_SERVER);
              dataWS.store(cMSKey, ms);
              and this in the JSP page:
              // Get the default T3Client Workspace
              WorkspaceDef defaultWS = t3.services.workspace().getWorkspace();
              // Attach to the system subWorkspace already created
              WorkspaceDef myDataWS = defaultWS.getWorkspace("DATA_WORKSPACE",
              WorkspaceDef.ATTACH,
              WorkspaceDef.SCOPE_SERVER);
              MimicServer ms = (MimicServer) myDataWS.fetch("MimicServer");
              Questions:
              1)Must I make the Object I want to store in the WorkSpace Serializable?? The
              Documentation says it can just be
              a Java Object??
              2) In my JSP page I get a good Object reference, but its contents are null
              (Probably because I didn't implement write() and read()).
              Thanks,
              matt obrien
              [email protected]
              Mark Griffith wrote:
              > Alexandre:
              >
              > Although byte for byte the FooObject is the same, according to the VM they
              > are different class. This is because a class's type distinctiveness is
              > based not only its interfaces,methods,data members etc but ALSO on its
              > classloader. There is a different classloader for the
              > serversclasses_FooObject and the servletclasses_FooObject so they are
              > considered different, so you get a CCE.
              >
              > Problem is that the servletclasses directory is designed to solve the
              > problem of reloading servlet classes and objects they used when modified
              > without having to restart the server. But this introduces the problem
              > discussed above. The only solution currently is to put the FooObject only in
              > one place or another. Unfortunately if you want a class in servletclasses
              > to interact classes loaded by the system/server classloader you cannot put
              > the class in the servletclasses without getting a CCE on reload of the
              > servlet in servletclasses. In this case you must put the class only in the
              > serverclasses directory. And this means of course you can only reload the
              > FooObject in the serverclasses directory if you bounce the server. (the
              > default java classloading behavior).
              >
              > This will be handled more elegantly in our next major release Spring 2000,
              > however note (and prepare by designing accordingly) the solution is to allow
              > the Servlet to interact with interfaces not actual classes and these
              > interfaces can be stuffed into system/server loaded classes such as
              > workspaces and httpsessions, thus preventing CCE's.
              >
              > Cheers
              > Mark G
              >
              > Alexandre Aubry wrote:
              >
              > > I have a named workspace which is created at startup of the server
              > > within a starup class.
              > > When the startup method is called, I instantiate and put an object
              > > called FooObject in the workspace.
              > >
              > > Then, in a servlet, called Dispatcher, in the service method, I
              > > retrieved my named workspace and the object
              > > FooObject which is in this workspace. At this time, I have a
              > > ClassCastException.
              > >
              > > To give you more details about my configuration, here is my directory
              > > configuration:
              > > weblogic
              > > |----------- serverclasses
              > > |------------- startupObject
              > > |------------- FooObject
              > > |----------- servletclasses
              > > |------------- myServlet
              > > |------------- FooObject (which is exactly
              > > the same of the serverclasses one)
              > >
              > > Do you have any ideas ? The idea is to instantiate a given object at the
              > > startup of the web server and to retrieve
              > > these objects within servlets and JSPs.
              > >
              > > Regards.
              > >
              > > --
              > > Alexandre Aubry
              > > Consultant
              > > Fi System, The Web Agency
              > > http://www.fisystem.fr
              > > mailto:[email protected]
              > > Phone: +33 1 55 04 03 03 Fax: +33 1 55 04 03 04
              >
              > --
              > =====================================================
              > Reply to the newsgroup. Don't reply to this mail
              > alias. This is used only for answering posts on
              > WebLogic Newsgroups.
              > =====================================================
              

  • How to convert this Servlet into JSP

    I am trying to convert this Servlet into JSP page.
    How do I go about doing this?
    Thanks.
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.text.*;
    /** Shows all items currently in ShoppingCart. Clients
    * have their own session that keeps track of which
    * ShoppingCart is theirs. If this is their first visit
    * to the order page, a new shopping cart is created.
    * Usually, people come to this page by way of a page
    * showing catalog entries, so this page adds an additional
    * item to the shopping cart. But users can also
    * bookmark this page, access it from their history list,
    * or be sent back to it by clicking on the "Update Order"
    * button after changing the number of items ordered.
    * <P>
    * Taken from Core Servlets and JavaServer Pages 2nd Edition
    * from Prentice Hall and Sun Microsystems Press,
    * http://www.coreservlets.com/.
    * &copy; 2003 Marty Hall; may be freely used or adapted.
    public class OrderPage extends HttpServlet {
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException {
    HttpSession session = request.getSession();
    ShoppingCart cart;
    synchronized(session) {
    cart = (ShoppingCart)session.getAttribute("shoppingCart");
    // New visitors get a fresh shopping cart.
    // Previous visitors keep using their existing cart.
    if (cart == null) {
    cart = new ShoppingCart();
    session.setAttribute("shoppingCart", cart);
    String itemID = request.getParameter("itemID");
    if (itemID != null) {
    String numItemsString =
    request.getParameter("numItems");
    if (numItemsString == null) {
    // If request specified an ID but no number,
    // then customers came here via an "Add Item to Cart"
    // button on a catalog page.
    cart.addItem(itemID);
    } else {
    // If request specified an ID and number, then
    // customers came here via an "Update Order" button
    // after changing the number of items in order.
    // Note that specifying a number of 0 results
    // in item being deleted from cart.
    int numItems;
    try {
    numItems = Integer.parseInt(numItemsString);
    } catch(NumberFormatException nfe) {
    numItems = 1;
    cart.setNumOrdered(itemID, numItems);
    // Whether or not the customer changed the order, show
    // order status.
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String title = "Status of Your Order";
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>");
    synchronized(session) {
    List itemsOrdered = cart.getItemsOrdered();
    if (itemsOrdered.size() == 0) {
    out.println("<H2><I>No items in your cart...</I></H2>");
    } else {
    // If there is at least one item in cart, show table
    // of items ordered.
    out.println
    ("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
    "<TR BGCOLOR=\"#FFAD00\">\n" +
    " <TH>Item ID<TH>Description\n" +
    " <TH>Unit Cost<TH>Number<TH>Total Cost");
    ItemOrder order;
    // Rounds to two decimal places, inserts dollar
    // sign (or other currency symbol), etc., as
    // appropriate in current Locale.
    NumberFormat formatter =
    NumberFormat.getCurrencyInstance();
    // For each entry in shopping cart, make
    // table row showing ID, description, per-item
    // cost, number ordered, and total cost.
    // Put number ordered in textfield that user
    // can change, with "Update Order" button next
    // to it, which resubmits to this same page
    // but specifying a different number of items.
    for(int i=0; i<itemsOrdered.size(); i++) {
    order = (ItemOrder)itemsOrdered.get(i);
    out.println
    ("<TR>\n" +
    " <TD>" + order.getItemID() + "\n" +
    " <TD>" + order.getShortDescription() + "\n" +
    " <TD>" +
    formatter.format(order.getUnitCost()) + "\n" +
    " <TD>" +
    "<FORM>\n" + // Submit to current URL
    "<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\"\n" +
    " VALUE=\"" + order.getItemID() + "\">\n" +
    "<INPUT TYPE=\"TEXT\" NAME=\"numItems\"\n" +
    " SIZE=3 VALUE=\"" +
    order.getNumItems() + "\">\n" +
    "<SMALL>\n" +
    "<INPUT TYPE=\"SUBMIT\"\n "+
    " VALUE=\"Update Order\">\n" +
    "</SMALL>\n" +
    "</FORM>\n" +
    " <TD>" +
    formatter.format(order.getTotalCost()));
    String checkoutURL =
    response.encodeURL("../Checkout.html");
    // "Proceed to Checkout" button below table
    out.println
    ("</TABLE>\n" +
    "<FORM ACTION=\"" + checkoutURL + "\">\n" +
    "<BIG><CENTER>\n" +
    "<INPUT TYPE=\"SUBMIT\"\n" +
    " VALUE=\"Proceed to Checkout\">\n" +
    "</CENTER></BIG></FORM>");
    out.println("</BODY></HTML>");
    }

    Sorry.
    actually this is my coding on the bottom.
    Pleease disregard my previous coding. I got the different one.
    My first approach is using <% %> around the whole doGet method such as:
    <%
    String[] ids = { "hall001", "hall002" };
    setItems(ids);
    setTitle("All-Time Best Computer Books");
    out.println("<HR>\n</BODY></HTML>");
    %>
    I am not sure how to break between code between
    return;
    and
    response.setContentType("text/html");
    Here is my coding:
    public void doGet(HttpServletRequest request,
    HttpServletResponse response)
    throws ServletException, IOException
         String[] ids = { "hall001", "hall002" };
         setItems(ids);
         setTitle("All-Time Best Computer Books");
    if (items == null) {
    response.sendError(response.SC_NOT_FOUND,
    "Missing Items.");
    return;
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();
    String docType =
    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
    "Transitional//EN\">\n";
    out.println(docType +
    "<HTML>\n" +
    "<HEAD><TITLE>" + title + "</TITLE></HEAD>\n" +
    "<BODY BGCOLOR=\"#FDF5E6\">\n" +
    "<H1 ALIGN=\"CENTER\">" + title + "</H1>");
    CatalogItem item;
    for(int i=0; i<items.length; i++) {
    out.println("<HR>");
    item = items;
    if (item == null) {
    out.println("<FONT COLOR=\"RED\">" +
    "Unknown item ID " + itemIDs[i] +
    "</FONT>");
    } else {
    out.println();
    String formURL =
    "/servlet/coreservlets.OrderPage";
    formURL = response.encodeURL(formURL);
    out.println
    ("<FORM ACTION=\"" + formURL + "\">\n" +
    "<INPUT TYPE=\"HIDDEN\" NAME=\"itemID\" " +
    " VALUE=\"" + item.getItemID() + "\">\n" +
    "<H2>" + item.getShortDescription() +
    " ($" + item.getCost() + ")</H2>\n" +
    item.getLongDescription() + "\n" +
    "<P>\n<CENTER>\n" +
    "<INPUT TYPE=\"SUBMIT\" " +
    "VALUE=\"Add to Shopping Cart\">\n" +
    "</CENTER>\n<P>\n</FORM>");
    out.println("<HR>\n</BODY></HTML>");

  • Location of java servlet (not jsp) deployed on Java Stack

    Hello,
    Why this forum? this post is related to the way of calling a java servlet deployed on the java stack, so it's related to the structure of the stack than to real java programming.
    Usually, I develop JSP servlets which are easily called either with a mapping or not. I have deployed now a java servlet and added a mapping to it by modifying the xml source itselft in its descriptor, but after deployement I am not able to reach the resource.
    In the windows explorer of the java stack I find in j2ee>cluster>server>apps my application as follows:
    app_ear>servlet_jsp>app>root>WEB-INF>classes>my class files
    app_ear>servlet_jsp>app>root>app.jsp
    This time it's not a jsp that I want to call: app/app.jsp but my java servlet which lies in the classes subdir.
    Could someone help my to achieve this or is it the wrong way, we can only request jsp applications?
    Kind regards,
    Tanguy Mezzano

    Hi Vladimir,
    here's my web.xml code:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
         <display-name>WEB APP</display-name>
         <description>WEB APP description</description>
         <servlet>
              <servlet-name>SSORedirect3.jsp</servlet-name>
              <jsp-file>/SSORedirect3.jsp</jsp-file>
         </servlet>
         <servlet-mapping>
              <servlet-name>AuthenticatorServlet</servlet-name>
              <url-pattern>/SSOredirect3</url-pattern>
         </servlet-mapping>
         <security-constraint>
              <display-name>SecurityConstraint</display-name>
              <web-resource-collection>
                   <web-resource-name>WebResource</web-resource-name>
                   <url-pattern>/*</url-pattern>
                   <http-method>GET</http-method>
                   <http-method>POST</http-method>
              </web-resource-collection>
              <auth-constraint>
                   <role-name>DefaultSecurityRole</role-name>
              </auth-constraint>
         </security-constraint>
         <security-role>
              <role-name>DefaultSecurityRole</role-name>
         </security-role>
    </web-app>
    And in my jsp file, I have a form with this kind of code:
    <form name="xyz" method="GET" action="http://j2eeserver:50000/SSOredirect3/SSOredirect3">
    I get this error in my logs:
    com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [SSOredirect3/servlet/AuthenticatorServlet] not found.
    Exception id: [000C299F469E00650001D8E900000CCC000458E27823275B]#
    Best regards,
    Tanguy Mezzano

  • Servlets vs JSPs

    Please help me figure out this: why there are people out there who would want to use both servlets and jsps for their web applications?

    In my old app, I used Servlets. In the Servlet, the
    HTML code was in the servlet, so was the business
    logic, so was the database access.
    Now I use JSP for the new app, and I have JSP with
    HTML, JavaBeans for logic, and other JavaBeans for db
    access.
    I think this setup is becoming the norm. Constructing your HTML inside a JSP is no problem at all, whereas with servlets, it required a little thinking, and usually some debugging too. Putting all your backend logic in JavaBeans is wonderful, and leaves your JSP pages "clean" of all the behind the scenes stuff, and lets them worry about interpreting the information and displaying it correctly.

  • Reloadable Servlet Classpath & JSP

    Is there any way to have the reloadable servlet classpath
              (weblogic.httpd.servlet.classpath) passed to JSP compiler? I will explain
              my problem as this may help you understand the question. I have my
              reloadable servlet classpath configure like this:
              weblogic.httpd.servlet.classpath=c:\weblogic\myserver\servlets. In addition
              to Servlets, this directory contains a number of JavaBeans that are used by
              my JSP pages. When WebLogic attempts to compile the JSP file, I receive
              errors because the compiler can't find the beans located in my
              weblogic.httpd.servlet.classpath. I can fix the problem by clearing the
              weblogic.httpd.servlet.classpath property and putting this directory in the
              system classpath. However, when I do this I need to stop and restart the
              WebLogic server everytime I change a servlet or bean.
              I've used both IBM WebSphere and J/Run. Both of these products feed the
              reloadable servlet classpath to the JSP compiler.
              Thanks for any help.
              Tom McAlees
              [email protected]
              

    Thomas,
              I think they might- but only if they are in the servlet classpath (possibly the
              weblogic.class.path too).
              Even so, the reason the servlets and JSP's reload is because the JPSServlet and
              servlet engine checks to see the servlet code or JSP code is new. This doesn't
              happen with your beans, so they ~probably~ won't get reloaded.
              -rrc
              homas McAlees wrote:
              > Prasad -
              >
              > I am aware of this solution, but it differs from the behavior I am used
              > to with IBM WebSphere and Aliar J/Run. I am trying to find out why I
              > can't have my Java Beans reload on modification just like my Servlets.
              > I've been developing this way for the past 9 months with other
              > Servlet/JSP engines and it really helps speed up development. The only
              > reason this seems to be a problem with WebLogic is the reloadable
              > classpath is not placed on the command line when the JSP compiler is
              > invoked. If I invoke the JSP compiler manually from the command line, I
              > can include the reloadable servlet classpath and things work o.k.
              >
              > Tom
              >
              > In article <[email protected]>, [email protected]
              > says...
              > > Tom,
              > > You should have your beans in weblogic/classes directory and if you want
              > > reload on modifying the servlets, the servlet classes shouldn't be in
              > > weblogic/classes. This way you don't have to restart the server whenever the
              > > servlets or jsp changes. If you have further questions please let me know.
              > >
              > > Thanks
              > > Prasad
              > >
              > > NA wrote:
              > >
              > > > Is there any way to have the reloadable servlet classpath
              > > > (weblogic.httpd.servlet.classpath) passed to JSP compiler? I will explain
              > > > my problem as this may help you understand the question. I have my
              > > > reloadable servlet classpath configure like this:
              > > > weblogic.httpd.servlet.classpath=c:\weblogic\myserver\servlets. In addition
              > > > to Servlets, this directory contains a number of JavaBeans that are used by
              > > > my JSP pages. When WebLogic attempts to compile the JSP file, I receive
              > > > errors because the compiler can't find the beans located in my
              > > > weblogic.httpd.servlet.classpath. I can fix the problem by clearing the
              > > > weblogic.httpd.servlet.classpath property and putting this directory in the
              > > > system classpath. However, when I do this I need to stop and restart the
              > > > WebLogic server everytime I change a servlet or bean.
              > > >
              > > > I've used both IBM WebSphere and J/Run. Both of these products feed the
              > > > reloadable servlet classpath to the JSP compiler.
              > > >
              > > > Thanks for any help.
              > > >
              > > > Tom McAlees
              > > > [email protected]
              > >
              > >
              Russell Castagnaro
              Chief Mentor
              SyncTank Solutions
              http://www.synctank.com
              Earth is the cradle of mankind; one does not remain in the cradle forever
              -Tsiolkovsky
              

  • Employee example:... resource [employee/servlet/NewEmployee.jsp] not found

    Hi,
    i installed an erp system 6.0 on windows server 2008. then i installed the netweaver developer studio on my local computer. i tried the example from the book: java-programmierung  mit dem sap web application server (dont know the english title)
    well, i deployd the example and wanted to see the jsp with the url: http://<servername>:<port>/employee/view
    this does not work, i get the following error:
    The request cannot be processed.
      Details:      
      com.sap.engine.services.servlets_jsp.server.exceptions.ServletNotFoundException: Requested resource [employee/servlet/NewEmployee.jsp] not found.
    Then i tried the url: http://<server>:<port>/employee/NewEmployee.jsp,  got following error:
    Application error occurred during the request procession.
      Details:      
      com.sap.engine.services.servlets_jsp.server.exceptions.WebIOException:
      Error compiling [/NewEmployee.jsp] of alias [employee] of J2EE application [sap.com/EmployeeEar].
    so i think theres something wrong with my jsp. but i dont see it.
    here is my jsp:
    <%@ page language="java" %>
    <html>
    <body style="font-family:Arial;" bgcolor="D2D8E1">
    <%@ page import="javax.naming.*" %>
    <%@ page import="javax.ejb.*" %>
    <%@ page import="com.sap.demo.*" %>
    <%@ page import="java.util.*" %>
    <h2>
    Register New Employee
    </h2>
    <form action="NewEmployee.jsp" method="POST" name="NewEmployee">
    <table border=0 align=center>
    <tr>
    <td width="220">First name: <td>
    <input type="text" name="firstname" value="" size="20">
    <tr>
    <td width="220">Last name: <td>
    <input type="text" name="lastname" value="" size="20">
    <tr>
    <td width="220">Department: <td>
         <select name="department">
         <option value="DEVELOPMENT">Development</option>
         <option value="TRAINING">Training</option>
         <option value="MANAGEMENT">Management</option>
         <option value="ARCHITECTURE">Architecture</option>
         </select>
    <tr>
    <td><td><br><input type="submit" value="Create" name="create">
    </table>
    <br>
    </form>
    <%
    String lName = request.getParameter("lastname");
    String fName = request.getParameter("firstname");
    String eDepartment = request.getParameter("department");
    if(lName == null || fName == null || lName.length() == 0 || fName.length() == 0)
    return;
    try{
    Context jndiContext = new InitialContext();
    Object ref = jndiContext.lookup("java:comp/env/ejb/EmployeeService");
    javax.rmi.PortableRemoteObject.narrow(ref, EmployeeServicesHome.class);
    EmployeeServicesHome empHome = (EmployeeServicesHome) ref;
    EmployeeServices empSession = empHome.create();
    long empId = empSession.registerEmployee(fName, lName, eDepartment);
    if(empId == 0)
    out.println("<H3> Failed! </H3>");
    else
    out.println("<H3> Success! </H3>");
    catch (Exception e) {
         out.println("<H3>"e.toString()"</H3>");
         e.printStrackTrace(System.out);
         return;
    %>
    </body>
    </html>
    if you see the reason or if you have andy idea why it doesnt work, please help me
    thank you

    Is it exactly how you have written ?
    out.println("
    "e.toString()"
    You can read it as:
    out.println(""e.toString()"");
    I do not think it is correct
    replace it either with
    out.println(""e.toString()"");
    OR
    out.println(e.toString());

  • How to get an ArrayList Object in servlet from JSP?

    How to get an ArrayList Object in servlet from JSP?
    hi all
    please give the solution for this without using session and application...
    In test1.jsp file
    i am setting values for my setter methods using <jsp:usebean> <jsp:setproperty> tags as shown below.
    After that i am adding the usebean object to array list, then using request.setAttribute("arraylist object")
    ---------Code----------
    <jsp:useBean id="payment" class="com.common.PaymentHandler" scope="request" />
    <jsp:setProperty name="payment" property="strCreditCardNo" param="creditCardNumber" />
    <%-- <jsp:setProperty name="payment" property="iCsc" param="securityCode" /> --%>
    <jsp:setProperty name="payment" property="strDate" param="expirationDate" />
    <jsp:setProperty name="payment" property="strCardType" param="creditCardType" />
    <%--<jsp:setProperty name="payment" property="cDeactivate" param="deactivateBox" />
    <jsp:setProperty name="payment" property="fAmount" param="depositAmt" />
    <jsp:setProperty name="payment" property="fAmount" param="totalAmtDue" /> --%>
    <jsp:useBean id="lis" class="java.util.ArrayList" scope="request">
    <%
    lis.add(payment);
    %>
    </jsp:useBean>
    <%
    request.setAttribute("lis1",lis);
    %>
    -----------Code in JSP-----------------
    In testServlet.java
    i tried to get the arraylist object in servlet using request.getAttribute
    But I unable to get that arrayObject in servlet.....
    So if any one help me out in this, it will be very helpfull to me..
    Thanks in Advance
    Edward

    Hi,
    Im also facing the similar problen
    pls anybody help..
    thax in advance....
    Litty

  • How do I lookup an EJB 3.0 Session bean from servlet or JSP?

    Does anyone knows how can I invoke an EJB from a servlet or JSP ?
    I deployed a simple EJB on a Oracle Application Server 10g release 10.1.3 and I'm working with JDeveloper 10.1.3. I deployed the files via JDeveloper, and I didn´t specify any orion-ejb-jar.xml or ejb-jar.xml file
    After deployment, the orion-ejb-jar.xml look like this in the server:
    <?xml version="1.0" encoding="utf-8"?>
    <orion-ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://xmlns.oracle.com/oracleas/schema/orion-ejb-jar-10_0.xsd" deployment-version="10.1.3.0.0" deployment-time="10b49516c8f" schema-major-version="10" schema-minor-version="0" >
    <enterprise-beans>
    <session-deployment name="HolaMundoEJB" location="HolaMundoEJB" local-location="HolaMundoEJB_HolaMundoEJBLocal" local-wrapper-name="HolaMundoEJBLocal_StatelessSessionBeanWrapper6" remote-wrapper-name="HolaMundoEJB_StatelessSessionBeanWrapper7" persistence-filename="HolaMundoEJB.home_default_group_1">
    </session-deployment>
    </enterprise-beans>
    <assembly-descriptor>
    <default-method-access>
    <security-role-mapping name="<default-ejb-caller-role>" impliesAll="true" />
    </default-method-access>
    </assembly-descriptor>
    </orion-ejb-jar>
    I'm trying to invoke the ejb in a servlet by doing the following:
    public void doGet(HttpServletRequest request, ....
    Context context = new InitialContext();
    HolaMundoEJB helloWorld =
    (HolaMundoEJB)context.lookup("java:com/env/ejb/HolaMundoEJB");
    String respuesta = helloWorld.sayHello("David");
    When i invoke the servlet I catch a NamingException whose message says something
    like this ....java:com/env/ejb/HolaMundoEJB not found in webLlamaEJB
    I tried different paths for the lookup but nothing....
    Can anyone help me with this topic? Thank you.

    Please try the following code:
    HelloEJBBean.java:
    @Stateless(name="Hello")
    @Remote(value={Hello.class})
    public class HelloEJBBean implements Hello {  ... }
    hello.jsp:
    Context ctx = new InitialContext();
    Hello h = (Hello)ctx.lookup("ejb/Hello");
    web.xml:
    <ejb-ref>
    <ejb-ref-name>ejb/Hello</ejb-ref-name>
    <ejb-ref-type>Session</ejb-ref-type>
    <remote>fi.kronodoc.test.model.Hello</remote>
    </ejb-ref>
    i think you should also define jndi mappings for the references in orion-ejb-jar.xml and orion-web.xml but for some reason it seems to be working also without these.

  • Error in accessing servlet from JSP

    Hello everybody,
    When I access a servlet from a JSP page,I am getting the following error message :
    Error 404--Not Found
    From RFC 2068 Hypertext Transfer Protocol -- HTTP/1.1:
    10.4.5 404 Not Found
    The server has not found anything matching the Request-URI. No indication is given of whether the condition is temporary or permanent.
    If the server does not wish to make this information available to the client, the status code 403 (Forbidden) can be used instead. The 410 (Gone) status code SHOULD be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address.
    I am using Weblogic 7.0 and my web.xml code is as follows:
    <web-app>
    <servlet>
    <servlet-name>TestServlet</servlet-name>
    <servlet-class>TestServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>TestServlet</servlet-name>
    <url-pattern>/TestServlet</url-pattern>
    </servlet-mapping>
    </web-app>
    I am accessing the servlet from a javascript function in my JSP page.
    I am quite new to the Java technology. So any help in this regard would be highly appreciated.
    Thanks in advance,

    The form action event is in a javascript function. I am sorry I mentioned that I am accessing this servlet from JSP. Actually,this servlet is accessed from an HTML document.
    The following is the javascript code:
    <script language="javascript">
    function lfnCallNext()
         alert("In the function");
         frmMain.method="POST";
         frmMain.action="/TestServlet";
         frmMain.hidChoice.value="GetList";
         frmMain.submit();
    </script>
    And this function is called from an hyperlink as follows:
    Work with Employee Database
    Thanks,

  • Change protocol when redirecting a request for a servlet to jsp

    Hello,
    In my servlet, There is a line of code:
    getServletConfig().getServletContext().getRequestDispatcher("/page.jsp").forward(request,response);
    My question is: I'd like to change the current protocol (like http) to new protocol (like https) or versa vista before my servlet executes the above line.
    Is this possible to implement that? If so, how can I do it?
    If not implement, Is there any ways to convert back or forward between http and https protocols in java, servlet or jsp?
    I did try to use window.location.href="protocol://myserver/..." in javascript to redirect the jsp page to the right protocol, but the session for the browser was lost, and the jsp page ran into infinite loop.
    Thanks in advance for any helps.
    Mike.

    if (!request.isSecure()) response.sendRedirect("https://me.com/page.jsp");
    (or visa versa)

  • Creating FOrums with Servlet and JSP

    Hi everyone,
    Is there a good resource that explains how to build a forum using servlets and JSP technology?
    Regards,
    Basil Mahdi

    please let me know here if you find any useful resources...I am in the process of writing my own searchable threaded forum for my company with JSP's/servlets. It's a very slow process at the moment though...if I ever finish it, I'll gladly share it.

  • Servlet and JSP in OAS

    I'm developing web application with OAS
    4.0.8.1 and JDeveloper 3.0 and I want to call
    JSP from servlet using "RequestDispatcher".
    I downloaded JSP for OAS from www.olab.com.
    In the Release note, there is a description
    about RequestDispatcher, but I cannot
    understand about details.
    In what configuration can I use servlet and
    JSP together with RequestDispatcher. Anyone
    scceeded about that?
    null

    wan (guest) wrote:
    : Hi everyone,
    : I am using OAS 4.0.8 on Solaris 2.6. After viewing servlet
    : and JSP samples, I am kind of confuse whether OAS supports the
    : following options
    : 1. JSP
    : 2. servlet chaining
    : 3. running JDeveloper DB Servlet wizard
    : (oracle.jdeveloper.servlet.*) and Java Business Objects
    : (oracle.jbo.rt.cs)
    : Thank you for your time.
    I found a white paper 408newfead.pdf, that says under "Future
    Directions" that it will add jsp support. I read somewhere (I
    can't remember where exactly :( ) that said 4.0.8.1 would
    support
    JSPs. I don't know if this release is out yet.
    I wish Oracle would get with the times and put out a product that
    is consistent with the technology they are touting as the
    future.
    Having us download Suns server to run servlets and JSP is
    ridiculous for the worlds second largest software company!
    null

  • JSP- Servlet-- Bean-- JSP how to implement

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow connects to DB and stores the value before putting to JSP.
    Iam using Tomcat 4.31
    Plz help me

    I have problem.
    My JSP will take a emplyee id .
    Now I want to show all the values regarding that
    employee in a JSP(JSP form) from the DB(Oracle).
    So Iam planning like
    JSP-->Servlet-->Bean-->JSP
    So my doubts are.
    1. Is it correct approach
    2.If it is correct then which part of the flow
    connects to DB and stores the value before putting to
    JSP.
    Iam using Tomcat 4.31
    Plz help meHI
    What you are probably proposing is an MVC design pattern. I wonder if u have heard of the struts framework. Sruts uses MVC design pattern wherein the servlet u are talking about acts as a controller(C) and the bean acts as the model(M) .The JSPs present the view(V). Hence the name MVC.
    Your approach is right. First get the employee ID from the jsp and get the corresponding data from database(This logic u implement in the servlet). Then save the fetched data in a bean so that the result jsp can fetch data from it.
    Now this is not a strict MVC approach.
    Learn more about struts. It presents a much more cleaner solution.

  • Serving Java Servlets and JSP

    I have a small hosting company and was wondering what is required to be installed on a Win2k Server to host Java Servlets and JSP pages for a client of mine?

    Ah, so you just want to add a servlet engine to IIS5?
    Tomcat can be used as a plugin for IIS. Check out the Tomcat FAQs - somewhere in there you should find one relating to using Tomcat as an IIS plugin. They're far more comprehensive than I could ever hope to be on the matter!

Maybe you are looking for