Accessing Servlet by jsp: forward

I want to access Servelt by hyperlink in a jsp web site
connection.jsp
<%@ page contentType="text/html;charset=GB2312" %>
<HTML>
<BODY bgcolor=cyan><Font size=1>
<A Href="/myjsp/Hello" >Accessing servlet<A>
</BODY>
</HTMLi put the bean in the dir(/myjsp/WEB-INF/classes/hello(package)/Hello)
and modify the file web.xml like this:
<servlet>
        <servlet-name>Hello</servlet-name>
        <servlet-class>hello.Hello</servlet-class>
    </servlet>
    <servlet-mapping>
       <servlet-name>Hello</servlet-name>
       <url-pattern>/Hello</url-pattern>
    </servlet-mapping>it works!
but if i use <jsp:forward>
<html>
     <body bgcolor="green">
     <jsp:forward page="/myjsp/Hello" />
     <body>
</html>it causes an Exception The requested resource (/myjsp/myjsp/SimpleServlet) is not available.
why? why the path have /myjsp/myjsp....?
Thanks

only one wrong u have done that is
U have to give :
<jsp:forward page="/Hello"></jsp:forward>
but not
<jsp:forward page="/myjsp/Hello"></jsp:forward>
the reason is that when u run a jsp file , a servlet is generated for that
jsp file. so calling a another servlet from that servlet(servlet of connection.jsp) can be done by just giving url -pattern. No need to give
/myjsp/Hello .
regards,
reply after u get

Similar Messages

  • 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,

  • Servlet to JSP forward issue

    I'm currently developing an app where I use a servlet as the controller and it forwards everything to a jsp for viewing. When I run the jsp as a standalone everything works fine, all of my javascript and css code. When I forward to it, all of my javascript code and css gets lost. Has anyone seen anything like this or have an explanation? Any help would be appreciated.
    Thanks,
    Mike

    Have you tried a different brower or view its textual response with telnet? there are some restricitons regarding servlet outputstream when forward is used (see Servlet spec 2.4 Section SVR.8.4, JSP Spec 2.0 section JSP.5.5). Any server log and stack trace and testcase will be helpful.

  • Accessing Servlets from JSPs

    Hi!
    I'm developing a web application with JSPs and servlets using JDeveloper 3.2.
    With the integrated web-to-go web server I can either start a JSP environment or a servlet environment.
    My question: What do I have to do to start the JSP environment with access to servlets?
    I tried to start the wizard Web Object Manager, but I get the error message "Could not load servlet information from Web Server". When I try to register a Servlet in this wizard, it will hang up.
    What's wrong? Are there any other possibilities to configure the web-to-go web server, so that I can access JSPs and servlets?
    Thanks for your help!
    Brian

    Hi!
    I finally found the solution myself.
    The problem was that the entry "HTML source" under "Project Properties" was empty. I entered "servlets" and started the "Web Object Manager" without any problem. My servlet was registered and I could access it from my JSP.
    I hope that you can benifits from my experience.
    Cu
    Brian

  • jsp:forward ... tag in servlet doesn't work in 7.0

              I have a problem with <jsp:forward ... > command.
              I found a post in the newsgroups that this is a bug traced by
              CR078071 and I am stucked because of this problem. Please, send me a patch.
              

              I have a problem with <jsp:forward ... > command.
              I found a post in the newsgroups that this is a bug traced by
              CR078071 and I am stucked because of this problem. Please, send me a patch.
              

  • Cannot invoke servlet from JSP

    I am trying to invoke a servlet from my JSP file. At present I am getting the error:
    500 Internal Server Error
    java.lang.IllegalArgumentException: Resource /servlet/CreateSPSS not found
         at com.evermind[Oracle Application Server Containers for J2EE 10g (10.1.2.0.2)].server.http.EvermindPageContext.forward
    I understand that my JSP cannot find my servlet but I cannot identify what the correct path or amendment is.
    My JSP file is located in:
    default-web-app/examples/jsp/com.xml2spss.jsp
    In the JSP my forward parameter is :
    <jsp:forward page="/servlet/CreateSPSS" />
    and my servlet (.java & .class) is located in
    default-web-app/WEB-INF/classes/com/pmstation/spss/site/servlet.CreateSPSS.java
    I have added the following line to Web.XML:
    <servlet-mapping>
    <servlet-name>CreateSPSS</servlet-name>
    <url-pattern>/servlet/CreateSPSS</url-pattern>
    </servlet-mapping>
    Where am I going wrong??
    Thankyou for any help at all on this one.

    Shaun,
    Nice to know that you find a way that works. However, what Zsolt suggests should work; otherwise, it is a bug. That is, put the servlet definition and servlet mapping in your web.xml and then you should be able to access http://host:port/myWebContext/servlet/CreateSPSS?myParmName=myParm without seeing a response like "No resource found". Please make sure that your servlet definition come before the corresponding servlet mapping.

  • JSP forward issue

    I have a web application deployed on weblogic 8 server. I have a jsp (AddNewUser.jsp) which forwards to a servlet (CreateUserServlet.class) with the following code :
    <jsp:forward page="/admin/CreateUser?userID=new"/>In the CreateUserServlet class, I have overriden init(config) as follows:
    public void init(ServletConfig config)throws ServletException {
             super.init(config);
            context = config.getServletContext();
    }In the doPost method, I have some debug statements as follows:
    public void doPost(HttpServletRequest request, HttpServletResponse response) {
    System.err.println("--------CreateUserServlet start------- ");
    //initialization code here    
    context.getRequestDispatcher("/WEB-INF/jsps/admin/createUser.jsp").forward(request, response);
    }The flow of actions is :
    1. User clicks on a link to AddNew.jsp which forwards to the CreateUserServlet
    2. The servlet performs some initialization (not shown) and forwards to createUser.jsp page
    3. The createUser.jsp page contains a form which the user fills and clicks "save".
    4. The form calls another servlet which saves the new user to the database.
    The problem now which I have is that the web application works perfectly on 4-5 test machines except for the client ( what luck huh?). For him this is what happens
    1. He clicks on a link to AddNew.jsp, he gets forwarded to the createUser.jsp page (as expected..no problem here!)
    2. He enters some data and clicks "save" and the new user gets saved to the database.(as expected..no problem here!)
    3. Now, when he tries repeating by clicking on the link to AddNew.jsp page, the debug statement "--------CreateUserServlet start------- " does not get printed to the console!!(HERE IS THE PROBLEM!) but he still gets forwarded to the createUser.jsp page! This is creating a problem because my initialization code is being skipped.
    So, the client is able to enter a new user the first time he visits the section but is not able to add thereafter.
    Any clues please?

    I wonder if what is happening is when he clicks the link to AddNew.jsp teh browser is pulling the page out of cache. That would explain why he gets the CreateUser form without hitting the CreateUserServlet.
    It is easy enough to check by enabling the access logs for your server. Then when he clicks on the link check the log to see if the request was recieved on the server and teh responce code is 304
    If it is a caching problem there are pleanty of examples of the HTML meta data tags to prevent cahcing on the forum if you search for them.

  • Passing value from Servlet to JSP back to Servlet

    Hi all,
    I have a jsp page where a user submits a search string into a text box. The jsp forwards to a servlet which calls some java classes and checks a database. The classes generate a string which contains some html. The servlet then forwards back to the jsp which displays the the string:
    <c:out escapeXml="false" value="${requestScope.ampList}" />The user then performs another action on this outputted html which is a listbox and when the user clicks on the listbox the onchange method submits the form. The JSP forwards the listbox value and I would like it to forward the "ampList" as well but I cant figure out how to do this.
    Using a hidden input does not work because the string contains HTML. Does anyone have any ideas. I can just keep the search string stored a hidden input box but I would prefer not to regenerate the "ampList" as it means accessing the database again which will cause performance issues.
    Thanks for any input in advance,
    Tom

    Ha,
    Writing that message gave me an idea which worked:
    <input type="hidden" name="ampList" value="<c:out escapeXml="true" value="${requestScope.ampList}" />" />

  • Blank page while servlet to jsp.

    Hi.
    am working in a code for login verification.
    In my login database i have different user.For each user user access will be different.
    So am verifying password for a particular user.The verification is done in servlet page .
    After verification am viewing only a blank page.
    Can u give me any suggestion.
    my code is given below.
    response.setContentType("text/html;charset=UTF-8");
            PrintWriter out = response.getWriter();
             HttpSession session=request.getSession();
            String user="",pass="";
            //ServletContext context=null;
            ServletContext context=getServletContext();
    String userName=request.getParameter("user").trim();
    String passWord=request.getParameter("pass").trim();
            String query="select * from login where user='"+userName+"' ";
           String DbUserName="";
           String DbPassword="";
           String finalUser="";
           try {
                 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                 Connection con1=DriverManager.getConnection("jdbc:odbc:register");
                  Statement stat=con1.createStatement();
                  ResultSet rst=stat.executeQuery(query);
                    while(rst.next())
         user=rst.getString("user");
    pass=rst.getString("pass");
                  if((userName.equalsIgnoreCase(user))&&(passWord.equalsIgnoreCase(pass)))
                session.setAttribute("user",user);
            context.getRequestDispatcher("/Mainmenu.jsp").forward(request,response);
            else
                   context.getRequestDispatcher("/LoginError.jsp").forward(request,response);
    catch(Exception e){
                 e.printStackTrace();
          }Thanks in advance,
    regards,
    satheeshkannan

    Indeed, you are just printing and ignoring the exception instead of throwing it or change the flow.
    Apart from this problem: why are you comparing the username once again after the query while the query should only return rows matching the username? Anyway, if your DB is well-designed (i.e. username is unique), then you can also just query for rows matching the username and the password so that you just need to check if ResultSet#next() returns true or not.
    Oh, don't forget to use PreparedStatement instead. It will save you from SQL injections.

  • Passing objects between Servlets and JSP

    Hi,
    I have passed a ResultSet from a Servlet to JSP using RequestDispatcher forward(). I can access the ResultSet in the JSP page. How can I now pass this ResultSet into another JSP page once the form has been submitted?
    Thanks in advance.

    You should never passing expensive resources like ResultSet around like that. This indicate an open DB connection somewhere while it should already be closed at this stage.
    Read on about the DAO pattern and make use of servlets and beans.

  • Not going to Servlet from JSP

              Hi,
              I have written a program that takes the email id and password from a jsp page and posts it to a servlet. The servlet had to get the parameters from the jsp and pass this values to a method called loginvalidation which inturn has to connect to data source and return true if the record exists else false if it doesn't exist. Now my problem is that the control is not passed from the jsp to the servlet(name:Login). It throws an Illegal access exception. What can be the problem? Can u provide a solution for this.
              

    The problem here is that your servlet doesn't implement doGet()
    doing a response.sendRedirect sends a web page back to the client, which then tries to load the servlet.
    It uses GET instead of POST because it is a standard URL link.
    Solution: implement doGet() in your servlet, even if all it does is call doPost() to do the same thing.
    You can also do a jsp:include, or jsp:forward to transfer control from a jsp to a servlet.
    However you are working in HTML, and you may not be able to get away from using an HTML form.
    Cheers,
    evnafets

  • Filter problem with jsp:forward

    Greetings,
    I was trying to implement compression filter in oc4j. Basically wrap a HttpResponseServletResponseWrapper using a GZipOutputStream for supported browsers. However whenever for eg: I have a.jsp which does jsp:forward page =b.jsp I can see in TCP monitor IllegalStateException response already committed. But I dont see any stack trace in server logs. The buffer size is 2048 and I am pretty sure it did not get filled up before the forward. I would appreciate if anybody has seen such behavior using wrapped response in OC4j(the same code works fine in tomcat and websphere). Also one thing I observed is that for every jsp:include the filter is being called (to handle this I create the wrapper if its not already there and maintain entry count into filter and decrement when I exit filter and finish gzip response when entry count become 0,which works fine). I believe that this is not a part of 2.3 spec.Even in 2.4 spec if the filter config in web.xml is not set to any value by default the filter is supposed to be in request scope. I really appreciate any pointers in resolving this

    I am pasting the stack trace for broken pipe exception. Please let me know if anybody knows the resolution. Please let me know if there is any other way to enable compression of jsp in oc4j in 9 version. The same code works in Jboss/tomacat websphere ! Also from the stack trace we can see that filter is being called for each forward and its not as per 2.3 servlet specification. Even in 2.4 by default the filter is supposed to work at request level.
    Also I have another question oc4j seems to be using hard coded value: if length is more than 100k or so it uses Transfer-Encoding chunked. Is there any clean way of disabling this behaviour for .js files? the reason is for some reason Internet explore does not cache the javascript files properly (sporadically ) when chunked response is used for javascript files.
    4/26/06 4:58 PM: com.evermind.server.http.HttpIOException: Broken pipe
    4/26/06 4:58 PM: at com.evermind.server.http.EvermindServletOutputStream.flush(EvermindServletOutputStream.java:286)
    4/26/06 4:58 PM: at java.io.FilterOutputStream.flush(FilterOutputStream.java:121)
    4/26/06 4:58 PM: at filters.gzip.GzipServletResponseStream.flush(GzipServletResponseStream.java:151)
    4/26/06 4:58 PM: at filters.gzip.GZipServletResponseWrapper.flushBuffer(GZipServletResponseWrapper.java:127)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:244)
    4/26/06 4:58 PM: at com.evermind.server.http.GetParametersRequestDispatcher.forward(GetParametersRequestDispatcher.java:189)
    4/26/06 4:58 PM: at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:199)
    4/26/06 4:58 PM: at SecondPage.jspService(_SecondPage.java:83)
    4/26/06 4:58 PM: at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    4/26/06 4:58 PM: at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    4/26/06 4:58 PM: at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    4/26/06 4:58 PM: at filters.CookieFilter.processRequest(CookieFilter.java:522)
    4/26/06 4:58 PM: at filters.CookieFilter.validateRequest(CookieFilter.java:127)
    4/26/06 4:58 PM: at filters.CookieFilter.doFilter(CookieFilter.java:51)
    4/26/06 4:58 PM: at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
    4/26/06 4:58 PM: at filters.gzip.GZipFilter.doFilter(GZipFilter.java:176)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.forward(ServletRequestDispatcher.java:240)
    4/26/06 4:58 PM: at com.evermind.server.http.GetParametersRequestDispatcher.forward(GetParametersRequestDispatcher.java:189)
    4/26/06 4:58 PM: at com.evermind.server.http.EvermindPageContext.forward(EvermindPageContext.java:199)
    4/26/06 4:58 PM: at FirstPage.jspService(_FirstPage.java:131)
    4/26/06 4:58 PM: at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
    4/26/06 4:58 PM: at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
    4/26/06 4:58 PM: at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    4/26/06 4:58 PM: at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
    4/26/06 4:58 PM: at filters.CookieFilter.processRequest(CookieFilter.java:522)
    4/26/06 4:58 PM: at filters.CookieFilter.validateRequest(CookieFilter.java:127)
    4/26/06 4:58 PM: at filters.CookieFilter.doFilter(CookieFilter.java:51)
    4/26/06 4:58 PM: at com.evermind.server.http.EvermindFilterChain.doFilter(EvermindFilterChain.java:16)
    4/26/06 4:58 PM: at filters.gzip.GZipFilter.doFilter(GZipFilter.java:176)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:556)
    4/26/06 4:58 PM: at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
    4/26/06 4:58 PM: at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
    4/26/06 4:58 PM: at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
    4/26/06 4:58 PM: at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
    4/26/06 4:58 PM: at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:803)
    4/26/06 4:58 PM: at java.lang.Thread.run(Thread.java:479)

  • 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.

  • 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>");

  • Is the jsp forward tag fails in iplanet application server sp2?

    11/Feb/2002 17:55:41:2] error: Exception: SERVLET-compile_failed: Failed in compiling template: /EinsWebTool/QueryScreen.jsp, Parse error in JSP parser. Missing endtag: /jsp:forward
    Exception Stack Trace:
    java.lang.Exception: Parse error in JSP parser. Missing endtag: /jsp:forward
    at java.lang.Throwable.fillInStackTrace(Native Method)
    at java.lang.Throwable.fillInStackTrace(Compiled Code)
    at java.lang.Throwable.<init>(Compiled Code)
    at java.lang.Exception.<init>(Compiled Code)
    at com.netscape.jsp.JSP.parseBlock(Compiled Code)
    at com.netscape.jsp.JSP.parseReqDisp(Unknown Source)
    at com.netscape.jsp.JSP.parseTag(Compiled Code)
    at com.netscape.jsp.JSP.parseNext(Compiled Code)
    at com.netscape.jsp.JSP.parseBlock(Compiled Code)
    at com.netscape.jsp.JSP.parse(Unknown Source)
    at com.netscape.jsp.JSP.compile(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.JSPtoJava(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileJSP(Compiled Code)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileOrLoadJSP(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPCompiler.compileInstance(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown Source)
    at com.netscape.jsp.PageContextImpl.forward(Unknown Source)
    at jsp.APPS.EinsWebTool.Login._jspService(Compiled Code)
    at jsp.APPS.EinsWebTool.Login.service(Login.java:42)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.callJSP(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callJspCompiler(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUri(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformHttpServletResponse.callUriRestrictOutput(Unknown Source)
    at com.netscape.server.servlet.platformhttp.PlatformRequestDispatcher.forward(Unknown Source)
    at com.netscape.server.servlet.jsp.JSPRunner.service(Unknown Source)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
    at com.netscape.server.servlet.servletrunner.ServletInfo.service(Unknown Source)
    at com.netscape.server.servlet.servletrunner.ServletRunner.execute(Unknown Source)
    at com.kivasoft.applogic.AppLogic.execute(Compiled Code)
    at com.kivasoft.applogic.AppLogic.execute(Compiled Code)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Native Method)
    at com.kivasoft.thread.ThreadBasic.run(Compiled Code)
    at java.lang.Thread.run(Compiled Code)

    Hi,
    Yes, I was able to code this sucessfully and got it working. Here is the code I used...
    <%
    String fortune = (String) request.getAttribute("fortune_string");
    %>
    <HTML>
    <HEAD><TITLE>Fortune Sample Application</TITLE></HEAD>
    <BODY BGCOLOR=#FFFFFF>
    <H2>The Oracular Servlet greets you!</H2>
    <p>
    Your fortune is...
    <%= fortune%>
    <p>
    <p>
    <hr size=0>
    <p>
    <FONT SIZE=2>Sample Applications
    <jsp:forward page="/ias-samples/index.html">
    </jsp:forward>
    </BODY>
    </HTML>
    and I got it working. I believe the code is missing some tag, which I tried, but got error in KJS like...
    [15/Feb/2002 11:23:49:7] info: --------------------------------------
    [15/Feb/2002 11:23:49:7] info: jsp.APPS.fortune.fortune: init
    [15/Feb/2002 11:23:49:7] info: --------------------------------------
    Null text data??
    2002-02-15 11:24:16 - error-the file '\fortune.jsp' generated the following pars
    e exception: org.apache.jasper.compiler.ParseException: C:\iplanet\ias6\ias\APPS
    \fortune\fortune\fortune.jsp(17,0) Expected "param" tag with "name" and "value"
    attributes after the "params" tag.
    In your case, I suspect, either the parser is not able to convert the .jsp file appropriately, or some inappropriate tag. If this doesn't help please send me your code & I can help you on this regard.
    Regards
    Raj
    [email protected]

Maybe you are looking for

  • Can i play my mac purchased iTunes content on a PC

    Hi, Times are hard and i can't afford to replace my dead Powerbook G4 with another Mac laptop so i'm thinking of buying a PC. However i have a lot of iTunes purchased music and films etc can and how do i get it all onto a windows PC? Also will it all

  • Automatic clean of Recent Folders list in Finder's "Go" menu: how I did it

    Hi everybody. I just would like to share with you the trick I have found to automatically clean the "Recent Folders" list in Finder's "Go" menu. It costed me some work but eventually it worked. I wanted it to run at shutdown. If it were executed at s

  • TS2917 Macbook pro retina leather case with magnets

    I've bought a new expensive leather case for my new macbook pro retina display. I've had my macbook accidentally fall asleep 3 or 4 times already. So, does it mean that I have to throw away that case? Or is it okay to keep using it unless I'm keeping

  • Does Flex Builder scale?

    Has anyone had success building large ActionScript projects in Flex Builder? Say 20,000 lines of ActionScript. Or is that not the way Flex is typically meant to be used? Thanks.

  • I am trying to install Lion OS X 10.7 over Mac OS X Snow Leopard 10.6.8

    I am trying to install Lion OS X 10.7 over Mac OS X Snow Leopard 10.6.8. I get an error message: "There are currently other logged in users, who must be logged out before you install Mac OS X". I switch to log out other users and deleted everyone lis