Accessing servlets using login and goto

Hi,
I'm having a problem in accessing servlets without visiting the DesktopServlet. There is no problem if the servlet does not require a parameter, but if I try to pass a parameter to the servlet, it does not pass the parameter -
Without visiting the DesktopServlet when I try to visit an servlet X , it gives me a session exception.
Thrown SessionException : Invalid service host name.
I use the following code to login and go to the servlet :
String redirectTarget = "login?&goto=" + req.getRequestURI() + "&hotelComponent=" + hotelComponent;
resp.sendRedirect(redirectTarget);
Inside the doGet of the servlet, I now try to read the hotelComponent parameter -
String hotelComponent = req.getParameter("hotelComponent");
But now I get a null. I can not get the hotelComponent parameter. Any suggestions will be very helpful
Thanks in advance
Partha

Thanks for the suggestions ! The original problem of not being able to pass parameters like -
"login?&goto=" + req.getRequestURI + "?param=" + value"
has been solved by encoding the URL string sent to resp.sendRedirect.
However the suggestion you have given regarding setting of cookies in the browser might have a bearing on my actual problem. I'm trying to do away with the redirection to the login servlet in the DesktopServlet.
Here is what I'm trying to do to make our website searchengine friendly - using WGET scrape the DesktopServlet and set it as the index.html. When somebody tries to access the links which are ordinary servlets, it gives a session exception. I catch the session exception and in the catch block use "login?&goto" to do a response.sendRedirect. This does a login and gets me the session.
All the servlets work fine except for one which is identical to the ones working except for the fact it is a post from a form on the DesktopServlet. Here I get a HTTP 400 Bad Request error. I've noticed that when I clear the cache and try I get a better response.
Any suggestion on how to overcome this ( possibly by setting cookies ) would be greatly appreciated.
Thanks in advance

Similar Messages

  • Login and goto fails

    Hi,
    I need to call a servlet directly without getting authenticated. The reason I need the session is because I'm using profile APIs. The method I'm trying out is using login and goto. In the user servlets, I get a session exception ( Invalid Service Host Name ) which I catch and in the catch block I use login and goto to get the session cookie and redirect to the user servlet.
    try{
    //Get session and profile here
    catch{
    redirectURL = "login?&goto=" + req.getRequestURI();
    resp.sendRedirect(redirectURL);
    This works if the servlet is called from a direct HREF link. If this servlet is posted from a form, it works at times but is very inconsistent. We get a BAD REQUEST on the browser when it fails.
    Any ideas why this happens ?
    Thanks

    Thanks for the suggestions ! The original problem of not being able to pass parameters like -
    "login?&goto=" + req.getRequestURI + "?param=" + value"
    has been solved by encoding the URL string sent to resp.sendRedirect.
    However the suggestion you have given regarding setting of cookies in the browser might have a bearing on my actual problem. I'm trying to do away with the redirection to the login servlet in the DesktopServlet.
    Here is what I'm trying to do to make our website searchengine friendly - using WGET scrape the DesktopServlet and set it as the index.html. When somebody tries to access the links which are ordinary servlets, it gives a session exception. I catch the session exception and in the catch block use "login?&goto" to do a response.sendRedirect. This does a login and gets me the session.
    All the servlets work fine except for one which is identical to the ones working except for the fact it is a post from a form on the DesktopServlet. Here I get a HTTP 400 Bad Request error. I've noticed that when I clear the cache and try I get a better response.
    Any suggestion on how to overcome this ( possibly by setting cookies ) would be greatly appreciated.
    Thanks in advance

  • Loading remote EJB from servlet using jakarta and openejb

    I am trying to create an environment where I use
    openejb as my EJB container, and JAKARTA Tomcat
    as my
    Servlet/JSP container. However,
    i'm having a problem in lookingup my remote EJB from my
    jakarta application.
    That exact code works perfectly if I run it standalone. I
    am using the same JRE. Jakarta has also loaded the
    openejb-0.8.3.jar and openejb_client-0.8.3.jar
    What I dont understand is why jakarta
    would behave differently than command-line java when I
    am
    running in the same JRE on a single machine.
    Any help would be much appreciated.

    Several fairly major improvements have been maid in OpenEJB specifically for the Tomcat people. For one, the whole way you integrate them has completely been rewritten. Now all you have to do is copy a openejb_loader-0.9.1.war into the Tomcat webapps directory and change an init-param in it. Pretty straight forward. OpenEJB 0.8.3 won't work with Tomcat in the same VM, however OpenEJB 0.9.0 and up have been totally revamped in all things related to classloading so that it can co-exist with Tomcats unique classloading architecture.
    O'Reilly just published an article detailing the ins and outs of the integration, it's a pretty good read:
    http://www.onjava.com/pub/a/onjava/2003/02/12/ejb_tomcat.html

  • Access frontrow using keyboard and mouse? is that possible

    in case i can´t find my notoriously missing apple remote?

    Use this key combo ⌘ esc. This will start frontrow from the keyboard.
    <

  • Trying to Access Website using SSL running JAVA from inside ORACLE DB

    Hi,
    I am trying to access website using SSL and running JAVA code from inside Oracle 10g DB server using SSL and Java. I have loaded my java code into Oracle data base. My problem is when I am running same code from outside the DB it is running perfectly fine but when the same code is loaded into DB and trying to run from DB under these environment I am using for running my code:-
    JDK 1.4.2_06
    JSSE 1.4
    Database :- Oracke 10G
    I am getting following Exception:-
    CALL testssl_http_mar20_New();
    java.io.IOException: Unable to tunnel through 123.456.789.123:80. Proxy returns "HTTP/1.1 407 Proxy Authentication Required ( The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied.)
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275
    at
    com.sun.net.ssl.internal.www.protocol.https.HttpsClient.doConnect(DashoA12275)
    at
    com.sun.net.ssl.internal.www.protocol.https.NetworkClient.openServer(DashoA12275
    at com.sun.net.ssl.internal.www.protocol.https.HttpClient.l(DashoA12275)
    at com.sun.net.ssl.internal.www.protocol.https.HttpClient.<init>(DashoA1
    2275)
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.<init>(DashoA
    12275)
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275
    at com.sun.net.ssl.internal.www.protocol.https.HttpsClient.a(DashoA12275
    at
    com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.connect(DashoA122
    75)
    at
    com.sun.net.ssl.internal.www.protocol.https.HttpsURLConnection.getInputStream(Da
    shoA12275)
    at java.net.URL.openStream(URL.java:924)
    at SecureURLhttp_Mar20_New.SecureURLhttp_Mar20_New(
    source code is below :-
    import java.io.*;
    import java.net.*;
    import java.security.*;
    import java.util.*;
        public class SecureURLhttp
              public static void main(String[] args) throws Exception
                  SecureURLhttp r = new SecureURLhttp();
                  r.SecureURLhttp();
        public static void SecureURLhttp() throws IOException
                System.setProperty("java.protocol.handler.pkgs","oracle.aurora.rdbms.url|com.sun.net.ssl.internal.www.protocol");
                System.setProperty("https.proxySet","true");
                Authenticator.setDefault(new MyAuthenticator());
                System.setProperty("https.proxyHost","123.456.789.123");
                System.setProperty("https.proxyPort","80");
               //  URL verisign = new URL("https://login.oracle.com/");
                URL verisign = new URL("https://www.verisign.com");
                BufferedReader in = new BufferedReader(new InputStreamReader(verisign.openStream()));
                String inputLine;
                while ((inputLine = in.readLine()) != null)
                System.out.println(inputLine);
                in.close();
                 /* Code Newly Add for checking the system property   */
                java.util.Properties props = System.getProperties();
                java.util.Enumeration propNames = props.propertyNames();
                 while (propNames.hasMoreElements ())
                 Object o=  propNames.nextElement();
                 String name = (String ) o;
                 String val =  props.getProperty(name)   ;
                 System.out.println ( name +  "  = "  + val );
        private static class MyAuthenticator extends Authenticator {
              protected PasswordAuthentication getPasswordAuthentication() {
                   return new PasswordAuthentication("<USERNAME>",new String("<USER_PASSWORD>").toCharArray());
         }Please help me out:
    Thanks a lot in advance.

    0- the fact the ISA server logs an 'anonymous' seems logical, since it answers by HTTP 407. I will say it's even a "good log" :) but I had preferred a good old "security exception" but it's not the case..
    1- The code for checking the properties (your debugging) should be placed BEFORE trying to connect to the url if you want to see what's happening
    2- The 'normal' way to set the proxy is to set the following properties
    System.setProperty("http.proxySet","true"); // and NOT https.proxyset as ejp said
    System.setProperty("http.proxyHost","123.456.789.123");
    System.setProperty("http.proxyPort","80");
    3- what's the behavior if you change 123.456.789.123 by the real name (hostname) of the server ?
    4- You can try setting up the proxy in the java control panel instead of in your code (easy to do under Windows, you look for the networking settings, and you find the proxy settings for http/https there. Otherwise look for all files called net.properties and edit them).
    5- to help debbuging, we can rely on several methods of Authenticator :
    protected PasswordAuthentication getPasswordAuthentication() {
    System.err.println(".\tgetRequestingHost: " + getRequestingHost());
    System.err.println("..\tgetRequestingSite: " + getRequestingSite());
    System.err.println("...\tgetRequestingPort: " + getRequestingPort());
    System.err.println("....\tgetRequestingProtocol: " + getRequestingProtocol());
    System.err.println(".....\tgetRequestingPrompt: " + getRequestingPrompt());
    System.err.println("......\tgetRequestingScheme: " + getRequestingScheme());
    return new PasswordAuthentication("<USERNAME>",new String("<USER_PASSWORD>").toCharArray());
    Try all this and let us see the output messages.
    Please remember to give some 'duke stars' if it helped resolving the problem ;)
    NephYliM

  • Web login (JSP, Servlet) with roles and users list stored using db4o

    Dear all,
    I would be grateful if someone of you (the masters out there) could help me with the build of an application where the first page will be a login page.
    The users will be devided in 3 categories (user, editor, administrator) and there member information will be saved in db4o database.
    If the user has not been registered in the past then a registration page should come up allowing him to be registered and keep his details in a db4o database on the same site.
    I am using JSEE8 and the site will be sent to a Tomcat server on the net.
    Please please please HELP

    I am giving some code for to redirect as the user is, But before that you have to made a extra coloumn "role" in your security table. and put admin, user as respective roles.
    doPost(HttpReq...........)
    String user = req.getParameter("UserName"):
    String pass= req.getParameter("Password");
    Then Connect the database with ur code ie class.forName etc
    String sql= "Select * from security_table where Username= ' "+user+" ' and Password= ' "+pass+" ' ";
    Statement stmt = conn.createStatement();
    ResultSet rs= stmt.exequteQuary(sql);
    if(rs.next)
    String S1=rs.getString("Username");
    String S2= rs.getString("Password");
    String S3= rs.getString("Role");
    if(S1.equals(user) && S2.equals(pass) && S3.equals.(admin)){
    req.sendRedirect(http:// full path name of the page)
    else if( S1.equals(user) && S2.equals(pass) && S3.equals.(user))
    req.sendRedirect(http:// full path name of the page)
    }else
    req.sendRedirect(http:// full path name of the Error page)
    }

  • MS access,servlets and jdbc-odbc

    when i try to connect to ms access database using servlet i get unable to open registry key DriverId problem.
    servlet successfully extracts the form data.Even jdbc code alone works fine, but when jdbc code is embeded in servlet I get the above error.I am using java web server 2.0 and a jdbc-odbc(type 1) driver.
    Please help me.................!
    I cannot proceed with my project without solving this problem.

    You have not specified the exception class.
    If it is java.security, try peeping into jws security directory, and set the access to your servlet directory.
    I do not know this helped you or not.
    regards

  • Client remote Authentication using JAAS and EJB Access

    Hi,
    I have a problem using JAAS in combination with Sun One Appserver 8.1 and a java remote client trying to access an EJB. Here is the scenario:
    I have implemented an EJB who's methods are protected through the deployment descriptor:
            <assembly-descriptor>
                 <security-role>
                    <description>role for clients outside of the server </description>
                    <role-name>sedna</role-name>
                  </security-role>
                <method-permission>
                  <role-name>sedna</role-name>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-intf>Remote</method-intf>
                    <method-name>*</method-name>
                  </method>
                </method-permission>
                <method-permission>
                  <unchecked/>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-name>getVersion</method-name>
                  </method>
                  <method>
                    <ejb-name>ServerInfoBean</ejb-name>
                    <method-name>create</method-name>
                  </method>
                </method-permission>
            </assembly-descriptor>I've deployed the EJB in a jar file which was packed into an ear file of a bigger application. The role has been mapped to the admin Principal in the sun-ejb-jar.xml descriptor.
    I can find the EJB, create it, and call the unchecked method getVersion and that works fine, so far so good.
    But then I try to access another method which is protected and then I get this exception
    org.omg.CORBA.NO_PERMISSION:   vmcid: 0x2000  minor code: 1806 completed: Maybe
            at com.sun.enterprise.iiop.POAProtocolMgr.mapException(POAProtocolMgr.java:179)
            at com.sun.ejb.containers.BaseContainer.postInvoke(BaseContainer.java:853)
            at com.sun.ejb.containers.EJBObjectInvocationHandler.invoke(EJBObjectInvocationHandler.java:137)
    ...I have to mention that I do make a login via the LoginContext. My jaas.config File has a reference to the com.sun.enterprise.security.auth.login.ClientPasswordLoginModule module.
    After login (which works perfectly) I lookup the context with a corbaname url which - if I understood it right - ignores the Context.SECURITY_PRINCIPAL and Context.SECURITY_CREDENTIALS settings.
    After that I make the calls to the EJB. And I am allways ANONYMOUS on the server side, which is definitely the problem. Because ANONYMOUS is not allowed to call the protected EJB Methods. But I made a jaas login in advance. So where am I making a mistake???
    Am I doing something wrong?
    Need help! Thx,
    Stephan

    Hi.
    I understand correctly that you call Subject.doAs on
    the client to call the remote EJB. I guess It isn't
    right way.I had also a bad feeling about this, so I forget it. But anyway it wasn't working with or without using that doAs().
    >
    >
    Subject contextSubject =
    Subject.getSubject(AccessController.getContext());
    contextSubject.getPrincipals();This code throws exceptions in the Appserver. Unfortunately they are catched somewhere so I'm unable to find out what was going wrong. But I guess, that these exceptions where security exceptions. Never the less thanks for the hint!
    But I don't think that doing the check on the server side is the way I want to go because that is programmatically security and I want to use the declarative security which can be used through the deployment descriptor. If used correctly - and supposed I do not completely misunderstand the specification - then it should be possible to create an EJB that is protected via it's deployment descriptor and access it through the client only if the client has been authenticated through JAAS mechanisms. After successful authentication the principal should be accessible through the EJB context but not for security check, that should allready been done at this time.
    Unfortunately I don't find any resource on the internet describing the scenario in such a detail that I can reproduce it. There are only very high level documentations and hints in forums.
    Again, thanks for your effort,
    Stephan

  • Showing various images on browser using JSP and Servlet

    Hello Guys!
    I am starting to develop in Java and already I am facing a big problem.
    If somebody will have some tip or suggestion, will be very well comings!
    The application must present in browser images originnally of format TIF. As it is not a native format of the I.E. , I converted the image for JPG (without saving it on disk) and send it to the browser a encoded image (encode) using JAI library in one servlet had access by a JSP. Then, the structure of my application is thus:
    1) an archive JSP draws the initial screen in browser and presents one input text.
    2) later that the user places the parameter, I make an access to the database and read a quantity of images to be presented.
    3) From there in the proper JSP, I use de tag img src to send image to the browser in agreement archive the amount of images.
    It follows the code of the JSP:
    <% 
                    int intI=0;
                    int intCont=0;
                    if(blnImagem == true){
                        out.println("<br>");
                        out.println("<table border=0 STYLE=border-collapse:collapse>");
                        out.println("<tr>");
                        for(intI=0;intI < Processo.intQtdImagens;intI++){
                           Imagem.strImgTif = Imagem.IndicarImagem(Processo.strNmPath,Processo.strSubPath,Processo.intNuImagem,intI);                                                                    
                           out.println("<th>");
                           out.println("<table border=1 STYLE=border-collapse:collapse rules='cols'>");
                           out.println("<tr>");
                           out.println("<th>");
                           %>
                             <img src="ShowImg" WIDTH=100>
                           <%
                           out.println("</th>");
                           out.println("</tr>");
                           out.println("</table>");
    %>and code on the ShowImg servlet:
            response.setContentType("image/jpeg");       
            ServletOutputStream sos = response.getOutputStream();
            RenderedOp src = JAI.create("fileload", Imagem.strImgTif);           
            ImageEncoder encoder = ImageCodec.createImageEncoder("JPEG",sos,null);       
            encoder.encode(src); 
            sos.close();The problem is if I have 10 images to present, it WILL BE it is executed 10 times and it passes 10 names of different archives, but in the page only the last image is presented 10 times. It is as if it processed the TAG to the end of everything in way that the value of the static variable Imagem.strImgTif was chore only with the last value and the same loaded image 10 times. How I make to solve this? Somebody has some idea?
    THANK YOU !
    Emidio

    If I understand correctly what your problem is:
    Do this in the jsp:
    out.println("<img src=\"ShowImg?image=" + intI + "\" WIDTH=100>");
    In the image servlet, get the "image" parameter and parse it as an int. Move the Imagem.IndicarImagem() call to the image servlet.

  • Using Firefox, I can login and browse my financial institution (NFCU) but I cannot pay bills. When I click the bill pay tab, the tab loads 66% and then hangs. Has anyone else reported having this issue?

    Using Firefox, I can login and browse my financial institution website (NFCU) but I cannot pay bills. When I click the bill pay tab, the tab loads about 66% and then hangs (loading). I have let it load until NFCU asks me if I want to cancel the session, a much to long of a load time. Has anyone else reported having this issue with NFCU or Mozilla Firefox 3.6.18?
    I have also posed the question to NFCU, currently awaiting response and will share what was given.

        jsavage9621,
    It pains me to hear about your experience with the Home Phone Connect.  This device usually works seamlessly and is a great alternative to a landline phone.  It sounds like we've done our fair share of work on your account here.  I'm going to go ahead and send you a Private Message so that we can access your account and review any open tickets for you.  I look forward to speaking with you.
    TrevorC_VZW
    Follow us on Twitter @VZWSupport

  • Accessing a web service defined in XI with login and password

    Hello,
    I've configured a web service on XI and made it available. I want to use it from a NWDS portal object. Accessing the page needs authentication.
    If I use XMLSpy to make a request I get an enter user login/password screen. But I don't know where i should  tell the login and password in my NWDS request.
    I tried to add the stuff in the url like this http://user:pass@host:port/... without success
    Does anyone know what is to be made in order to let me access my web service ?
    In NDWS I get my service ...
    (Service) myservice = PortalRuntime.getRuntimeResources().getService("MY/Service");
    MyResult myResult = myservice.makeRequest()
    Thx,
    mejj

    Check out
    http://hcc.musc.edu/research/shared_resources/xml_complex_types_to_cf_structure_notes.cfm
    The last part of that link is .cfm - not sure why its getting
    cut off.

  • When to use jsp,and when to use servlet?

    I think that jsp and servlet can realize the same functions, because when run a jsp, it is transferred to a servlet program, so when to use jsp and when to use servlet?
    I am now developing the input interface for a website, I just use jsp and javabean to connect to weblogic and database, and I didn't use servlet, Is there any unseemliness?
    Thank you!

    IMHO I use servlets to control the flow between my jsp's based on a number of factors in a webapp. For instance, user authorization. If a user has the authorization to conduct various administrative functions on an application (like change user rights, reset passwords etc) they will have access to specific buttons or links on some screens that others will not. I use servlets to establish what access rights a user has and direct them to the appropriate pages. I also use servlets to test data validity on form input screens. I know that I can also do this with JavaScript but that can be disabled by the client and in order to prevent that I also double check the form input from a servlet. All my jsp's do is display the results of a business process (which is held in a JavaBean or EJB) and the servlets act as the controllers for the application, connecting to multiple databases, verifying application state, flow control etc. I try to keep the jsp as simple as possible as some of them are maintained by html developers who lack the necessary experience to write java code. I hope this helps.

  • Problem - Custom Page Call Working via APPS login and not using CRM login

    I have created a custom link in the Oracle Portal order page. The call (click) works correctly when I login using a regular apps login and choose ORDER STATUS , but if I login directly to CRM and then access the same page via clicking on ORDER PORTAL image, the link doesn't work --> it seems to get translated to something I am not familiar with. I have illustrated the problem below, and am trying to figure out what to do to make the CRM login environment work as well.
    Thanks.
    Channeld
    Code modification to the CO -->
    String dest_url = "OA.jsp?OAFunc=XXX_ONT_FUNC_129&Header_ID_p="+Header_ID;
    OAUrl oaurl = new OAUrl(dest_url);
    dest_url = oaurl.createURL(pageContext);
    osb.setDestination(dest_url);
    --> what the link shows in on the order page using both logins
    http://pl1ua121.corio.com:8000/OA_HTML/OA.jsp?OAFunc=XXX_ONT_FUNC_129&Header_ID_p=11261&_ti=1811750263&oapc=5&oas=grPSiOwvEyLuXdxKt_a5GA..
    --> what the link gets translated to once clicked within a CRM login session; note, during a regular apps login,
    the link does not get translated.
    http://pl1ua121.corio.com:8000/OA_HTML/RF.jsp?function_id=27070&resp_id=50661&resp_appl_id=672&security_group_id=0&params=08V2jKe4UMpLbUVYUjsT8ZCABTTWpQnO7QdLdJyREFbPg8IIF5.vbStfOY8IYonLVX-dbml9UlrBKO.-rfzhVC2iib.jk6vv-9lnvaN2g5jHG7dKBUwLdgDx0woWFYmOIGTJJxkjHrHfmNMIqDTmxzD8K-jXUU8Vqja8Ajn98ZYtdz6iVvq.yKvS3fbGlxu7vsBw20gV7Yp8gAp9Ps90OUg.5HJh9CD8FhYpiJp4ffQ

    Hi,
    Thanks for the update.
    Sir its not about calling the JSP Page from OAF page.
    My requirement is what I have explained above.
    Please suggest its urgent.
    Thanks,
    Raja Dutta

  • Need Help Badly on Shopping Cart Using JSP And Java Servlet

    Hi All,
    This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
    I have read through a few acticles but i still do not get the whole idea of how it works.
    Please guide me as i need help very badly.
    Thanks.
    This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
    <html>
    <head>
    <title>Purchase Order</title>
    </head>
    <body topmargin="30">
    <table border="0" width="100%" id="table1" cellpadding="2">
         <tr>
              <td bgcolor="#990000" width="96">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Code</font></b></td>
              <td bgcolor="#990000" width="260">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Description </font></b></td>
              <td bgcolor="#990000" width="130">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
              </font></b></td>
              <td bgcolor="#990000" width="146">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
              </font></b></td>
              <td bgcolor="#990000" width="57">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="62">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Carton<br>
              Price </font></b></td>
              <td bgcolor="#990000" width="36">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
              Qty</font></b></td>
              <td bgcolor="#990000" width="65">
              <p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
              To Cart</font></b></td>
         </tr>
    <tr>
    <td align="center" width="96" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
    </td>
    <td align="center" width="260" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
    </td>
    <td align="center" width="130" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
    </td>
    <td align="center" width="146" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
    </td>
    <td align="center" width="57" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
    </td>
    <td align="center" width="62" bgcolor="#CCCCCC">
    <font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
    </td>
    <td align="center" width="36" bgcolor="#CCCCCC">
    <!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
    <p align="center"><input type="Integer" name="Q10005" size="1"></p>
    </td>
    <td align="center" width="65" bgcolor="#CCCCCC">
    <p><input type="checkbox" name="checkbox" value="123"></p>
    </tr>
    <tr>
    </table>
    <table border="0" width="100%" id="table2">
         <tr>
              <td>
              <div align="right">          
                   <input type="hidden" name="hAction" value="AddToCart"/> 
              <input type=submit name="submit" value="Add To Cart"/>                     
    </div>
    </td>
         </tr>
    </table>
    </body>
    </html>
    After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
    import javax.servlet.http.*;
    import javax.servlet.*;
    import java.io.*;
    import java.util.*;
    import java.util.ArrayList;
    public class AddToCartControlServlet extends HttpServlet
         public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
              String action = req.getParameter("hAction");
              if (action.equals("AddToCart"))
                   addToCart(req,res);
         public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
              try
                   String url = "";
                   String[] addList = req.getParameterValues("checkbox");
                   HttpSession sess = req.getSession(true);
                   //String sessionID = sess.getId();
                   DBClass dbClass = new DBClass();
                   ArrayList cartList = new ArrayList();
                   for (int i = 0; i < addList.length; i++)
                        String productCode = (String)addList;
                        int qty = Integer.parseInt(req.getParameter("Q"+productCode));
                        Products product = dbClass.getProductDetail(productCode);
                        double totalUnitAmt = qty * product.getUnitPrice();
                        double totalCartonAmt = qty * product.getCartonPrice();
                        Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
                        cartList.add(order);
                   sess.setAttribute("cartList", cartList);
                   url = "/Cart/CartDetails.jsp";
                   ServletContext sc = getServletContext();
                   RequestDispatcher rd = sc.getRequestDispatcher(url);
                   rd.forward(req, res);
              catch (Exception e)
                   System.out.println(e);
    From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
    From there, user would be able to remove or to continue shopping by selecting other category.
    How i do store all the items user has selected ... everytime he would wan to view his cart ...
    As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.

    Hi !
    Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
    Then , you can change the cart accordingly .
    Hope this works.
    Cheers ,
    Pranav

  • Any tutorials on creating a simple Login using Mysql and sessions?

    Hey guys. I cannot seem to find any information(online) or books that cover sessions in JSF and how to do a simple log in. I can get the application to query a mysql table and check the credentials and go to the next page, but I'm not sure how to make that page locked from non authorized access. I am very familiar with PHP and using it to create database driven applications. It's very straightforward, making safe logins using mysql, and creating sessions once the user has logged in(making pages locked unless the user is logged in, etc).. I have the core java server faces book but it's a joke. I feel like its an incomplete book. It merely skims a topic, and when you think it's going to get interesting it moves on to something else. It teaches basic stuff but nothing of what I want to do(or need to do). The older Javaserver faces book that came out in 2004 from O'Reilly doesn't seem to help either. I'm just wondering where people learn JSF at. I know Java, I would say pretty well as far as desktop applications go. I really like the way JSF is layed out and would really like to use it in my next project. At the level I know it now it's perfect for static web pages with no dynamic information.(but I could use plain html for that). Thanks for all your help.

    dothedru22 wrote:
    but I'm not sure how to make that page locked from non authorized access.You can use a Filter for that. Map the filter on the desired url-pattern and write doFilter() logic which checks if the user is logged in (basically: if there is an User object in the HttpSession) and handle accordingly (chain.doFilter() on success or response.sendRedirect on fail).
    and creating sessions once the user has logged in(making pages locked unless the user is logged in, etc).. The HttpSession is backed by a cookie (as is PHP's $_SESSION, did you know that?), you don't need to do any low-level stuff with cookies. Maybe at highest if you ever want a "remember me on this computer" option.
    booksThe mentioned books learns you the JSF basics. They doesn't really learn the best practices / practical use cases. There you have other resources for (or just practical experiences). Besides, I recommend you to go get a book which covers JSF 1.2 or newer. The mentioned ones are outdated, as is everything else older dan two years in the programming world.

Maybe you are looking for

  • CS3 - How to swap media on the sequence?

    I will try my best to explain my question, but basically if anyone is familiar with Final Cut Pro, I'm referring to the ability to "linking media" to a clip. Basically I re-organized my files on my harddrive and when I opened up an old edit, I needed

  • Set hyperlink in excel

    I am importing one excel file INPUT.xls which contain one columnl with hyperlink which opens a PDF file. From this file i am generating a new file with that hyperlinked column Which contain the same link as INPUT.xls file has. How can i get that link

  • Wanted: Popup which allows the user to enter one string

    Hello, as the topic states, I am searching for a (modal) popup which lets the user enter one string in a text field and returns this string. I am currently using the function module 'POPUP_TO_GET_ONE_VALUE' for this purpose which works quite good - B

  • Explorer slow showing folders containing PDF files

    I have Windows XP SP2 and Acrobat Pro 7.0.9 on a Dell Precision M65 about 4 months old. Windows Explorer experiences a significant delay displaying the contents of folders that contain large PDF files. Process Explorer shows that during these delays

  • No utl_dbws.jar in classpath!...no really...

    I am trying to complete the this user guide http://www.oracle.com/technology/sample_code/tech/java/jsp/callout_users_guide.htm and all it's fine until this C:\Documents and Settings\florinp\My Documents\wsdl>jpub -u infows/infows@oradev -sysuser sys/