Access SSL pages from servlet

Hi,
I request your assistance with the following please:
I have a web application running on tomcat4.1 with mySql, for enrolment.
It consists of pages :
1- Welcome page
2- Personal details part 1
3 - Personal details part 2
4 - Authorize to save to database
Page 1 goes to a servlet that sets beans etc..
I need to then proceed to page 2->3->4 with an SSL protocol. I have purchased a certificate and the hosting company has confirmed that it is installed.
I would welcome some direction on how to modify the code from the following :
theURL="page2.jsp";
RequestDispatcher dispatcher=request.getRequestDispatcher(theURL);
dispatcher.forward(request, response);
to get to page 2 within an SSL layer.
Your advice will be greatly appreciated.
Thank you.

Found the solution.
In the doGet method add:
SessionBean1 sessionBean1 = (SessionBean1) req.getSession().getAttribute("SessionBean1");       

Similar Messages

  • Urgent....How can i redirect to my jsp page from servlet in init() method..

    How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
    using RequestDispatcher..its not possible..becoz
    RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
    rd.foward(req,res);
    Here the request and response are null objects..
    So mi question can frame as how can i get request/response in servlet's init method()..

    Hi guys
    did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
    java.net.SocketException: Unexpected end of file from server
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
    at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
    nection.java:519)
    at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
    at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
    at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
    so plz do let me know how to call a jsp in the start up of a servlet.
    Thanks
    Vidya

  • How can I display the HTML page from servlet which is called by an applet

    How can I display the HTML page from servlet which is called by an
    applet using the doPost method. If I print the response i can able to see the html document. How I can display it in the browser.
    I am calling my struts action class from the applet. I want to show the response in the same browser.
    Code samples will be appreciated.

    hi
    I got one way for this .
    call a javascript in showDocument() to submit the form

  • Stop user accessing portal pages from book marks(favourites)

    Hi,
    Scenario... a user can log into portal and set pages as book marks in their browser (favourites), then close the ssession(and browser); then reopen the browser and access the page from the book mark, portal forces the user to log in (which is good) but I don't want them to have access to the page book marked, I want them to be always sent to the main page instead.
    Is it possible to stop this happening.
    Thanks in anticipation
    DG

    Hi,
    I am afraid this cant be done. The only thing is that the user will be forced to login.
    Thanks,
    Sharmila

  • Cannot access APEX pages from other IP in the same network

    Hi,
    I installed APEX 3.0 on Oracle XE (Windows OS). The PC I installed has a static IP (no DHCP and DHCP servie is stopped).
    I started the HTTP server and I am able to access the XE database home page and the APEX developer page and admin page. This PC has a static IP too.
    When I tried to access the APEX page from another PC. It is not loading the page.
    When tried using Internet Explorer it says "Internet Explorer Cannot display the page"
    Please let me know whether I missed any configurations to the access the page from another IP.
    Thanks.
    Niko

    Hi,
    Most likly the cause is windows firewall. Try the following:
    1 - from Control panel select windows firewall
    2 - click on the exception tab
    3 - Click Add port
    4 - for name enter yhe name you want (APEX)
    5 - For port number enter APEX prot number
    Hope that will solve your problem
    Regards,
    Ribhi

  • Can display Web pages from servlet but not applet?

    I have been able to display real-world Web pages from a simple servlet using JDeveloper 3.0, but can't figure out how to do the same from an applet. Any hints?

    My previous post had the detail...Probably a simple question from a relative novice. I'm having a problem just viewing web pages by calling them from a "list" of URLs in an applet. I built an applet with a split pane that has a JTree on one side and an "HTML viewing pane" on the other. I can click JTree nodes to display local html files, but I don't understand how to display web pages from the Internet. Do I need something like HyperlinkListener to make the jump to "hyper-world"???

  • How to access a page from another website in to the portlet

    Hai,
    I need this specific requirement. In a portlet that is written in jsp, i need to access another page which is running in another server.I will explain what is my requirement clearly.. In a portlet, i have to acess a page from another site, and i have to pass a parameter directly. If i use URL-Based Portlet with passing parameters, It ask the user to enter the parameter and submit the page.. But what my need is, i have to pass the parameter directly. what i am planning is in a new tab, i will add a portlet, where i need to access the another website page..when the user opens that tab, it directly shows that website..... How do i proceed...
    Can anybody help me.. Its URGENT....
    If possible send me the code..
    my mail id: [email protected]
    Thanks in advance
    damodar

    Damodar,
    To include an existing JSP page as a portlet have a look in the PDK section http://portalcenter.oracle.com there is lots useful information. The two things you might find most relevant is a paper on creating java portlets. This paper has a section on turning an existing JSP page into a portlet
    http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/ARTICLES/HOW.TO.BUILD.A.JAVA.PORTLET.USING.PDK.JAVA.V2.HTML
    and to pass parameters and events
    http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/ARTICLES/OVERVIEW.PARAMETERS.EVENTS.HTML
    Hope this helps,
    Candace

  • Exception while accessing com port from servlet

    I am trying to access communication port from a Servlet using java communications api's.
    But Following exception was thrown
    Caught java.lang.NullPointerException:name can't be null while loading driver com.sun.comm.Win32Driver
    The SecurityManager do not allow that opeartion.
    java.security AccessControlException:access denied (java.io.FilePermission c:\j2sdk1.4.1\jre\lib\javax.comm.properties delete)
    at java.security.AccessControlContext.java:270) at java.security.AccessController.checkPermission(SecurityManager.java)
    at java.lang.SecurityManager.checkDelete()
    at java.comm.CommPortIdentifier.getPortIdentifiers(CommportIdentifier.java)
    Please help me.Tell me what to do.how to successfully access a communication port from a Servlet.

    Hi there. I am also facing the problem accessing com port via servlet. if u have the solution, kindly forward to me at [email protected]
    many thanks

  • Security Exception while accessing com port from servlet

    I am trying to access communication port from a Servlet using java communications api's.
    But Following exception was thrown
    Caught java.lang.NullPointerException:name can't be null while loading driver com.sun.comm.Win32Driver
    The SecurityManager do not allow that opeartion.
    java.security AccessControlException:access denied (java.io.FilePermission c:\j2sdk1.4.1\jre\lib\javax.comm.properties delete)
    at java.security.AccessControlContext.java:270) at java.security.AccessController.checkPermission(SecurityManager.java)
    at java.lang.SecurityManager.checkDelete()
    at java.comm.CommPortIdentifier.getPortIdentifiers(CommportIdentifier.java)
    Please help me.Tell me what to do.how to successfully access a communication port from a Servlet.

    Well, have you tried the obvious to add the following permission to your web server's policy file?
    grant "file:<wherever my servlet resides>\myservlet.jar" {
    permission java.io.FilePermission "c:\j2sdk1.4.1\jre\lib\javax.comm.properties", "write,delete";
    }

  • Can't access ssl pages

    My friend got a PowerBook G4 from a family member.  It runs 10.4.11.  First thing off the bat: It wont connect using WPA2-Enterprise.  Browsing works, but not for any SSL pages.  (Safari and Firefox)
    I am told it worked just fine.  So I suspect someone deleted vital keychain information prior to giving it to him.  Could someone direct me how to recover from this.

    Hello,
    If it's the original 802.11b Airport card, it's limited to WEP or WPA, no WPA2.
    TenFourFox is the most up to date browser for our PPCs, they even have G4 & G5 optimized versions...
    http://www.floodgap.com/software/tenfourfox/
    SeaMonkey seems pretty fast also, with many options...
    http://www.seamonkey-project.org/
    http://www.seamonkey-project.org/releases/
    Might try reapplying the big 10.4.11 combo update...
    The combo update for PowerPC-based Macs...
    http://www.apple.com/support/downloads/macosx10411comboupdateppc.html
    Repair Permissions afterwards, reboot.

  • Need to Call OA Page from Servlet

    Hi All,
    My requirement is to call OAF page from the servlet.
    Can anyone please give me some pointers to achieve this.
    Thanks
    Anoop

    hi
    anoop ,check if this thread can help u
    how to call a OA page from a jsp page
    thanx
    Pratap

  • Access jspx page from af:region

    hi
    jdeveloper 11.1.2.3
    i have a jspx and inside it there is dynamic bounded task flow , how can i refresh parent page from this dynamic region.
    tnanks

    Hello,
    The "RefreshCondition" attribute into Property Inspector of af:region, you could set the condition (EL expression) to refresh only
    the region (returns true) or the parent page (returns false).
    http://suneesh-adf.blogspot.com/2013/09/refreshing-adf-region.html
    rfh.

  • Accessing a page from login page without login

    hi gurus,
    i have a link on my login page, for example-- about company. if i try to access it, it will always ask for login first and then go to that about company page. can i access this page without logging in?
    i saw some solutions like hidden region displayed on same login page, but what if i need to navigate to a different page?
    nadeem

    Hi Nadeem,
    As long as the page has no functionality on it - typical for things like "Terms and Conditions" etc, then you can just make that page public. Edit the page attributes and set Authorization Scheme to "-No Page Authorization Required-" and set Authentication to "Page is Public".
    That way, the page can be seen by anyone whether they are logged in or not.
    Andy

  • Output byte[] (image) to JSP page from Servlet - not working - why??

    I'm testing some new code in my servlet. I'm changing the method I use for pulling an image from the db (which is stored in a Blob column) and then displaying it in a Jsp page via <img src="go.callServlet">
    The new way works up until the code that outputs the image (bytes).
    Here's a snippet of the code -
                   rs = stmt.executeQuery("Select image from images");
                   rs.next();
                   Blob blobimage = rs.getBlob(1);          
                   int index = 0;             
                in = blobimage.getBinaryStream();        
                BufferedImage orig = ImageIO.read(in);    
                //resize image
                GraphicsConfiguration gc = getDefaultConfiguration(); //calls method in servlet
                 BufferedImage image = toCompatibleImage(orig, gc); //calls method in servlet                   
                 final double SCALE = (double)max_Width_Large/(double)image.getWidth(null);
                 int w = (int) (SCALE * image.getWidth(null));
                 int h = (int) (SCALE * image.getHeight(null));
                 final BufferedImage resize = getScaledInstance(image, w, h, gc);
                   //convert bufferedimage to byte array
                   ByteArrayOutputStream bytestream = new ByteArrayOutputStream();                                        
                  // W R I T E                                        
                  ImageIO.write(resize,"jpeg",bytestream);                                                                      
                  byte[] bytearray = bytestream.toByteArray();
                  bytestream.flush();
                  res.reset();
                   res.setContentType("image/jpeg");                   
                   while((index=in.read(bytearray))!= -1 ) {                         
                             res.getOutputStream().write(bytearray,0,index);
                   res.flushBuffer();              
                   in.close();     
                   //....               I know for a fact that the process of getting the image as a blob, making a BufferedImage from it, having the BufferedImage resized, and then converted into a byte[] array, works! I tested by putting the result into a db table.
    I just don't understand why it is that as soon as it gets to the code where it should output the image, it doesn't work. Its frustrating:(
    Here's the code I use regularly to output the image to the jsp, works all the time. The reason I've changed the method, is because I wanted to resize the image before displaying it, and keep it to scale without losing too much quality.
    rs = stmt.executeQuery("Select image from testimages");
                   rs.next();
                   Blob blobimage = rs.getBlob(1);
                   int index = 0;             
                in = blobimage.getBinaryStream();
                  int blob_length = (int)blobimage.length();
                  byte[] bytearray = new byte[blob_length];
                  res.reset();
                  res.setContentType("image/jpeg");
                   while((index=in.read(bytearray))!= -1 ) {
                             res.getOutputStream().write(bytearray,0,index);
                   res.flushBuffer();
                   in.close();     
    //...Can someone shed some light on this trouble I'm having?
    Much appreciated.

    I hate to bother you again BalusC, but I have another question, and value your expertise.
    With regards to using the BufferedInput and Output Streams - I made the change to my code that is used for uploading an image to the db, and I hope I coded it right.
    Can you please take a look at the snippet below and see if I used the BufferedOutputStream efficiently?
    The changes I made are where I commented /*Line 55*/ and /*Line 58*/.
    Much appreciated.
         boolean isPart = ServletFileUpload.isMultipartContent(req);
             if(isPart) { //40
              // Create a factory for disk-based file items
              FileItemFactory factory = new DiskFileItemFactory();
              // Create a new file upload handler
              ServletFileUpload upload = new ServletFileUpload(factory);                    
              java.util.List items = upload.parseRequest(req); // Create a list of all uploaded files.
              Iterator it = items.iterator(); // Create an iterator to iterate through the list.                         
              int image_count = 1;
         while(it.hasNext()) {                                                       
              //reset preparedStatement object each iteration
              pstmt = null;
                 FileItem item = (FileItem)it.next();     
                 String fieldValue = item.getName();     
                 if(!item.isFormField()) {//30
              //when sent through form
              File f = new File(fieldValue); // Create a FileItem object to access the file.
              // Get content type by filename.
                 String contentType = getServletContext().getMimeType(f.getName());
                 out.print("contenttype is :"+contentType+"<br>");                    
                 if (contentType == null || !contentType.startsWith("image")) {                               
                     String message = "You must submit a file that is an Image.";
                     res.sendRedirect("testing_operations.jsp?message="+message);
                       return;
              }//if
              //#### Code Update 3/18/09 ####
    /*line 38*/     BufferedInputStream bis = new BufferedInputStream(new FileInputStream(f));
              BufferedImage bug_lrg_Img = ImageIO.read(bis);                                           
              //code to resize the image;
              BufferedImage dimg = new BufferedImage(scaledW,scaledH,BufferedImage.TYPE_INT_RGB);
              //more code for resizing
              //BufferedImage dimg now holding resized image                           
                  ByteArrayOutputStream bytestream = new ByteArrayOutputStream();
                // W R I T E
                /* Line 55 */     
                   /*  ??? - is a BufferedOutputStream more efficient to write the data */
                   BufferedOutputStream bos = new BufferedOutputStream(bytestream);
                   /*line 58 */     
                   //changed from  ImageIO.write(dimg,"jpg",bytestream);                                  
                   //to
                   ImageIO.write(dimg,"jpg",bos);
              // C L O S E
              bytestream.flush();
                   /* Line 63 */
                   byte[] newimage = bytestream.toByteArray();                    
              pstmt = conn.prepareStatement("insert into testimages values(?)");                              
              pstmt.setBytes(1,newimage);
              int a = pstmt.executeUpdate();     
                   bis.close();
                bytestream.close();
                   bos.close();
                  //...

  • Error while accessing bean created from servlet

    Hi there
    I have a jsp page form home.jsp where i am collecting user name and password and then directing to a LoginServlet.Here if the user is validated then i create a accMasterBean and store it in Session object which i create here and then redirect to profile.jsp
    In the profile.jsp page i am using bean as follows:--
    <jsp:useBean id="accMasterBean" scope="session" class="AccountMaster">
    <jsp:setProperty name="accMasterBean" property="*"/>
    </jsp:useBean>
    i am fetching the properties of this bean in profile.jsp itself and try to display as shown below:---
    <%=accMasterBean.getAccountNumber() %>
    where accountNumber is a property defined inside AccountMaster class
    but it gives an error as follows :---
    <input type="text" name="emailAddress" value="Exception generated ---javax.servlet.ServletException: Exception thrown on line '205' from page 'D:\\Program Files\\Allaire\\JRun\\servers\\default\\emtech2\\jsp\\members\\profile.jsp'.
    Plz note if remove the above line of fetching the property of bean in profile.jsp page then there is no error
    Hoping to get a reply soon
    Thanking u
    Mumtaz
    The code for LoginServelt is given below
    ====================================
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.sql.*;
    public class LoginServlet extends HttpServlet{
         private Connection conn=null;
         public void init(ServletConfig config)throws ServletException{
              super.init(config);
         public void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
         try{
              Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
              conn=DriverManager.getConnection("jdbc:odbc:emt");
         }catch(ClassNotFoundException e){System.out.println("Error loading database driver");}
         catch(SQLException e){     System.out.println("SQL Exception in Databse driver");     }
         PrintWriter out = null;
         out=response.getWriter();
         response.setContentType("text/html");
         Statement st=null;
         ResultSet rs=null;
         String aN=null;
         String pN=null;
         String accountNumber1=null;
         String pinNumber1=null;
         String alternatePassword1=null;
         String emailAddress1=null;
         String firstName1=null;
         String lastName1=null;
         String address1=null;
         String zipPostalCode1=null;
         String city1=null;
         String state1=null;
         String country1=null;
         String companyName1=null;
         String title1=null;
         String homePhone1=null;
         String workPhone1=null;
         String mobilePhone1=null;
         String pager1=null;
         String faxNo1=null;
         String website1=null;
                        //Date dob;
         String dateOfBirth1=null;
         String gender1=null;
         String securityStatus1=null;
                        //Date doreg;
         String dateOfRegistration1=null;
         int noOfAccounts1=0;
         int noOfAttempts1=0;
         String remarks1=null;
         try{
              aN=request.getParameter("accountNumber");
              pN=request.getParameter("pinNumber");
              st=conn.createStatement(); // creating a statement to execute
              rs=st.executeQuery("SELECT * FROM ACCOUNT_MASTER where AccountNumber=\'" + aN + "\' and PinNumber= \'"+pN +"\' ;");
              while (rs.next())
                        accountNumber1=rs.getString("AccountNumber");
                        pinNumber1=rs.getString("PinNumber");
                                                           //alternatePassword1=rs.getString("alternatePassword");
                        emailAddress1=rs.getString("EmailAddress");
                        firstName1=rs.getString("FirstName");
                        lastName1=rs.getString("LastName");
                        address1=rs.getString("Address");
                        zipPostalCode1=rs.getString("ZipPostalCode");
                        city1=rs.getString("City");
                        state1=rs.getString("State");
                        country1=rs.getString("Country");
                        companyName1=rs.getString("CompanyName");
                        title1=rs.getString("Title");
                        homePhone1=rs.getString("HomePhone");
                        workPhone1=rs.getString("WorkPhone");
                        mobilePhone1=rs.getString("MobilePhone");
                        pager1=rs.getString("Pager");
                        faxNo1=rs.getString("FaxNo");
                        website1=rs.getString("WebSite");
                        gender1=rs.getString("Gender");
                        break ;
         // closing the connection
         rs=null;
         st=null;
         conn.close();
    if((accountNumber1.equals(aN))&&(pinNumber1.equals(pN))){
         // create all beans address and userprofile
         HttpSession session=request.getSession();// creating the session
         AccountMaster accMasterBean=new AccountMaster();
         accMasterBean.setAccountNumber(accountNumber1);
         accMasterBean.setPinNumber(pinNumber1);
         accMasterBean.setEmailAddress(emailAddress1);
         accMasterBean.setFirstName(firstName1);
         accMasterBean.setLastName(lastName1);
         accMasterBean.setAddress(address1);
         accMasterBean.setZipPostalCode(zipPostalCode1);
         accMasterBean.setCity(city1);
         accMasterBean.setState(state1);
         accMasterBean.setCountry(country1);
         accMasterBean.setCompanyName(companyName1);
         accMasterBean.setTitle(title1);
         accMasterBean.setHomePhone(homePhone1);
         accMasterBean.setMobilePhone(mobilePhone1);
         accMasterBean.setWorkPhone(workPhone1);
         accMasterBean.setPager(pager1);
         accMasterBean.setFaxNo(faxNo1);
         accMasterBean.setWebsite(website1);
         accMasterBean.setGender(gender1);
    session.setAttribute("accMasterBean",accMasterBean);// setting the account bean in the session attribute
         getServletConfig().getServletContext().getRequestDispatcher("/jsp/members/profile.jsp").forward(request,response);
    }else{
         // do some processing for account field and pasword field not set and return back to main page
         getServletConfig().getServletContext().getRequestDispatcher("/jsp/signup.jsp").forward(request,response);
    }// end of try
    catch(SQLException e){out.println("SQL Exception generated in LoginServlet---"+e);}
    catch(Exception e1){ out.println("Exception generated in LoginServlet---" + e1);}
    finally{
    try{
         if(conn!=null) conn=null;
         if (rs!=null) rs=null;
         if(st!=null) st=null;
    }catch(Exception e){out.println("Exception closing database connections "+e);}
    } // end of doPost
         public void destroy(){
              try {
                   if(conn!=null) conn=null;
         catch (Exception e) { System.out.println("Error closing database connection"); }
         public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{ doPost( request, response);}
    }//end of loginservlet
    =======================================

    Hi everyone
    I have got the solution
    Thanks
    Mumtaz

Maybe you are looking for

  • How to correct journals for non inventory items

    Hi All, One of my client by mistake made a non-inventory item as an inventory item and used FIFO valuation. Now he has created some 30 purchase invoices, goods receipt PO for it in the last month. While doing month end they reconcillation they realiz

  • How do I get the export value of a combox upon opening a document?

    I can't find a way to access the currently selected export value from a combobox upon opening a PDF document (without a keystroke event), so I'm using a very ugly trick (I have a function with a switch statement that returns a value that matches the

  • Possible bug using count in sort statement

    I think there may be a bug in using count as the means to sort nodes. Below is an example of what I am describing. It appears that when the sort is performed the number of nodes is accurately calculated for each item. I printed the values out and han

  • Want a FaceTime Handle

    I want a FaceTime name, or handle, I can publish on business cards and such. Skype gives you a handle but who wants to use Skype on apple devices? Not me. I've read about controlling your FaceTime caller ID. You can control which phone number or emai

  • In BD87  T /c  is it possible to control user based in Comp code...?

    In BD87  T /c  is it possible to control user based in Comp code...? Thanks Mahi