Intiating a Faces session Through Servlet

Hi all,
I have an application that is run as a servlet. It will link to a Faces application that I have written, and the application will have to start with its component tree populated based on variables passed through the servlet.
I don't really know how to go about doing this. Can the original servlet invoke a FacesContext, populate the component tree, and then pass the results to a browser? Is there a smarter way to go about accomplishing what I need?
Thanks,
Elam Daly

Hi,
amother way to add fonctionality to servlet is ServletFilter.
ServletFilter acts as a Decorator pattern.
You can add many filter on many servlet.
Check on the web for more info about it.
Hope this could help you.
Regards,
Sebastien Degardin.

Similar Messages

  • Problem in opening .ics and .vcs file types through servlet in IE browser.

    I'm having problem in downloading an .ics and .vcs file through servlet in I.E browser. It is happening fine in Mozilla firefox(they both are getting opened in OutLook), but in IE it says as undefined file type.
    I'm using Content Type as : 'text/Calendar' and then setting header as :
    response().setContentType("text/Calendar");
    response().setContentLength(file.length());
    response().setHeader("Content-Disposition", "attachment;
    filename="+filepath);
    and after that i'm writing it to OutPut stream.
    Plz Help.

    Hi,
    On page load check whether the session values are there. If not redirect the user to the login page.
    Hope this helps,
    Regards,
    Sammani

  • Not able to retrieve data from database through servlet

    Hi friends,
    I am trying to open a excel sheet through servlet. In this servlet i am retriving data from mssql database.I am not getting any error but no data is retrived
    i m also pasting the code here
    // Decompiled by Jad v1.5.8f. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3)
    // Source File Name:   EmployeeData.java
    import java.io.*;
    import java.sql.*;
    import javax.sql.*;
    import javax.servlet.ServletException;
    import javax.servlet.http.*;
    public class EmployeeData extends HttpServlet
        public EmployeeData()
        public void service(HttpServletRequest httpservletrequest, HttpServletResponse httpservletresponse)
            throws ServletException, IOException
            httpservletresponse.setContentType("text/html");
            httpservletresponse.setHeader("Content-Type", "application/excel");
            httpservletresponse.setHeader("Content-Disposition", "filename=reports.xls");
            PrintWriter printwriter = httpservletresponse.getWriter();
            try
                javax.servlet.http.HttpSession httpsession = httpservletrequest.getSession(true);
                int i = 0;
             /*   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:microsoft:sqlserver://localhost:3413;DatabaseName=newreportsodbc", "reportuser", "cisco");*/
                String url="jdbc:odbc:newreportsodbc";
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                Connection connection = DriverManager.getConnection("jdbc:odbc:newreportsodbc","reportuser","cisco");
                Statement statement = connection.createStatement();
                printwriter.println("<b><center><u> Search Results </u></center></b>");
                printwriter.print("<table><tr><th color=brown background-color=#fff000>  No.  </th>");
                printwriter.print("<th> DateTime      </th></tr></table>");
           ResultSet resultset = statement.executeQuery("SELECT * FROM t_Call_Type_Half_Hour");
                boolean flag;
                for(flag = false; resultset.next(); flag = true)
                    i++;
                    SerialNo = resultset.getString(2);
                    printwriter.print((new StringBuilder()).append("<table><tr><td> ").append(i).append("</td>").toString());
                    printwriter.print((new StringBuilder()).append("<td> ").append(SerialNo).append("</td></tr></table>").toString());
                if(!flag)
                    printwriter.println("<h1> No records selected </h1>");
            catch(Exception exception)
                System.out.println((new StringBuilder()).append("SQLException: ").append(exception).toString());
        static String empid1;
        static String empid;
        static String SerialNo;
        static String designation;
    }thanks in advance. i just feel there is something to be done with connection string.

    post the table format in SQL

  • Store Image through Servlet

    I want to store a JPG image into database column through Servlet
    and dispaly it on a JSP page through Beans
    how can i ?

    Any requests made to a JSP are of a certain content. Generally you make a request to a JSP page it sends back a "text/html" document. There is noi binary data as such just text.
    Images on a page are displayed because the "src" attribute of the image tag points to a server location. This in turn returns content of type "image/*".
    A servlet can retrieve/generate your images for you for example you could point to a servlet:
    <img src="/system/imageServlet">
    I guess a JSP can do the same (I've never tried it) just remember to set the response.contentType to "image/gif"/"image/jpg".....
    Cheers,
    Anthony

  • How to Create a session in Servlet

    will somone show me the code to create a session in servlet?
    if a session can be created in servlet file, it can be used all the jsp files in a same web ?
    Thanks!!!

    Session in Java web application is started by the web server itself.
    In a servlet you can get the session by
    HttpSession session = request.getSession();
    It will return the current session associated with this request, or if the request does not have a session, creates one.

  • Objects through servlet

    How to pass the object through servlet?

    I can venture a guess that the OP wants to 'send' an object as a request parameter or a form field.
    You'd have to turn the object into some data representation that can later on be translated back into the object; serialization comes to mind. It might be easier to just send the properties of the object as seperate request/form fields though!

  • Insert Arabic through Servlet

    Hi,
    I am able to read Arabic characters through servlets and able to display in a browser .
    But when I try to insert Arabic characters to Oracle Database through servlets ,
    it is saved as ??????? or inverted question marks
    Kindly help me resolve this issue.
    Thanks and Regards
    Jailani

    and since email replies won't work with the "<>" chars in them:
    in application.cfm
    <cfset setEncoding("url","UTF-8")>
    <cfset setEncoding("form","UTF-8")>
    <cfcontent type="text/html; charset=UTF-8">
    at the top of your cf pages add:
    <cfprocessingdirective pageEncoding="UTF-8">

  • Oracle NoSQL through Servlet.

    Hello Everyone,
    I am trying to execute the nosql operations on server through servlet. I want to make an client server application but dont know why the CONNECTION TO KVSTORE IS NOT ESTABLISHED WHILE EXECUTING ON SERVLET.
    So is there any separate configuration needed to do so?
    Thanks In Advance.

    Could you be more explicit please?  What is the exact error you are seeing?
    Please explain in detail what is the issue you're facing.
    If you want to access an Oracle NoSQL Database KVStore through a servlet the best way would be to use a ServletContextListener in your web app that gets the KVStore handle and places it in application/context scope as an attribute (so that all servlets and JSPs would have access to it) and also closes the handle when the web app gets shut down.  You could even supply the store name, store host name and store host port (the helper host port -- hostName:hostPort) through the web.xml web app config file.
    Here is a simple example of such a ServletContextListener:
    import javax.servlet.ServletContext;
    import javax.servlet.ServletContextEvent;
    import javax.servlet.ServletContextListener;
    import javax.servlet.annotation.WebListener;
    import oracle.kv.KVStore;
    import oracle.kv.KVStoreConfig;
    import oracle.kv.KVStoreFactory;
    * KVStoreClientContextListener implements ServletContextListener, hence it will be
    * invoked when the application context is initialized and destroyed.
    * @author Andrei Costache
    @WebListener
    public class KVStoreClientContextListener implements ServletContextListener {
        @Override
        public void contextInitialized(ServletContextEvent sce) {
            ServletContext sc = sce.getServletContext();
            KVStore ondbstore = null;
            try {
                // Try to get the store name, store host name and store host port from web.xml,  as context attributes.
                // If they are not available, then default to the values specific to a default KVLite instance.
                String storeName = (String) sc.getAttribute("storeName");
                String hostName = (String) sc.getAttribute("hostName");
                String hostPort = (String) sc.getAttribute("hostPort");
                if (storeName == null) {
                    storeName = "kvstore";
                if (hostName == null) {
                    hostName = "localhost";
                if (hostPort == null) {
                    hostPort = "5000";
                // Get the KVStore and place it as an atribute in application/context scope.
                ondbstore = KVStoreFactory.getStore(new KVStoreConfig(storeName, hostName + ":" + hostPort));
                sc.setAttribute("ondbstore", ondbstore);
            } catch (Exception e) {
                sc.log("Could not get a KVStore instance");
        @Override
        public void contextDestroyed(ServletContextEvent sce) {
            KVStore ondbstore = null;
            ServletContext sc = sce.getServletContext();
            try {
                ondbstore = (KVStore) sc.getAttribute("ondbstore");
                if(ondbstore != null) {
                    ondbstore.close();
            } catch (Exception e) {
                sc.log("Could not successfully close the KVStore handles");
    In your servlets or JSPs you will simply retrieve the KVStore handle from the servlet context, where it is found as a context scope attribute:
    KVStore ondbstore = (KVStore) getServletContext().getAttribute("ondbstore");
    and do whatever operations you want using the KVStore handle.
    You will need the NoSQL Database kvclient.jar -- either your web container / application server can load it, or you could copy it under the WEB-INF/lib directory so that it gets loaded when your web app gets deployed and started.  (kvclient.jar is found under kv-M.N.P/lib).
    Regards,
    Andrei

  • How to process batch input session through program

    Hi Friends,
    I am getting 5 batch input sessions in SM35,but  I want to process these all sessions through program without going to SM35.
    How it is possible through Program?
    Please Guide me!
    Thanks,
    Yogesh

    Hi,
    It's the report to run the batchinput sessions.
    When you create to B.I. session, you can execute it by transaction SM35 (but it uses rsbdcsub) or rsbdcsub.
    For example you can use it in the same program where you create B.I.:
    Here the code to fill the structures of FI batch input
    standard....
    ...here it creates session...
    SUBMIT RFBIBL00 WITH DS_NAME = VA_FILE
    WITH CALLMODE = CALLMODE AND RETURN.
    ....here it runs session....
    SUBMIT RSBDCSUB WITH MAPPE = P_NAME
    WITH VON = SY-DATUM
    WITH BIS = SY-DATUM
    WITH FEHLER = ' '
    TO SAP-SPOOL
    LIST NAME P_NAME
    LIST DATASET P_NAME
    COVER TEXT P_NAME
    NEW LIST IDENTIFICATION ' '
    EXPORTING LIST TO MEMORY
    AND RETURN.
    regards,
    Shiva.

  • Session in servlet

    Good morning my dear friends
    can nay one explain y we are not using "new" operator to create a object for session in servlet ?

    Please take care, that the http protocoll is a stateless protocoll. Without special actions it is not possible to say that this request come from user x and so on.
    So you have to use a session.
    Create the SessionObject with the request object like this:
    HttpSession session = request.getSession(true);
    So, now you have a session. This session is identified by a cookie or with some additional work with the sessionid in the url.
    If you don't use persistent data you don't have to know which client make the request! Is you use it then store the data with the session object.
    If you really need to know the name from the client / user you have to make a login .
    I hope this help
    regards Dietmar

  • Session in Servlet and JSP

    Hi
    How do I maintain a session in the scenario below:
    (1) Servlet A creates a session
    (2) Servlet A dispatch JSP A
    (3) JSP A capture some user inputs and post to Servlet B
    So far both (1) and (2) are working fine, but to get on to (3) the session is lost upon reaching Servlet B
    Pls Advise...

    Hi mirage2000,
    You mean that when you are calling the Servlet B, the request object has no session inside it's a bit strange.
    Let's take the following example wich is quite simple:
    Servlet A:
    package servlet;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServletA extends HttpServlet {
    public void init (ServletConfig config) throws ServletException {
    super.init(config);
    public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    doPost(req, res);
    public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    String nomClient = "Toto";
    HttpSession session = null;
    try {
    session = req.getSession();
    req.setAttribute("servlet.a.nom", nomClient );
    getServletConfig().getServletContext().getRequestDispatcher("/jspa.jsp").forward(req, res);
    } catch (Exception e) {
    System.out.println("Pas cool !");
    JSP A:
    <%@ page import="java.util.*"%>
    <% String nom = (String)request.getAttribute("servlet.a.nom"); %>
    <HTML>
    <HEAD><TITLE>Age ?</TITLE></HEAD>
    <BODY>
    <BR>
    <BR>
    What is your age ?
    <BR>
    <FORM ACTION="../servlet/ServletB" METHOD="post">
    <INPUT TYPE="text" NAME="age" SIZE="3">
    <BR>
    <INPUT TYPE="submit" NAME="action" VALUE="SEND"> </FORM>
    </BODY>
    </HTML>
    Servlet B:
    package servlet;
    import java.io.*;
    import java.util.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServletB extends HttpServlet {
    public void init (ServletConfig config) throws ServletException {
    super.init(config);
    public void doGet (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    doPost(req, res);
    public void doPost (HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
    HttpSession session = null;
    PrintWriter out = res.getWriter();
    try {
    String action = req.getParameter("action");
    if (action.equals("SEND") ) {
    res.setContentType(CONTENT_TYPE);
    session = req.getSession();
    String age = (String)req.getParameter("age");
    String nomClient = (String)session.getAttribute("servlet.a.nom");
    out.println("<HTML><HEAD></HEAD><BODY>");
    out.println("Hello mister <B>" + nomClient + "</B>");
    out.println("<BR>You are <B>" + age + "</B> years old !!");
    out.println("</BODY></HTML>");
    out.flush();
    out.close();
    } catch (Exception e) {
    System.out.println("Pas cool !");
    This exemple is really simple and is working perfectly on my Apache Tomcat test server.
    Be more precise maybe you forgot to do some stuff.
    Regards
    Julien

  • Running an executable file through servlet

    Hello People,
    I tried searching about this on the Forums, but could not find the right solution.
    Please donot get annoyed if you find this to be a repeted topic, which I am sure is not.
    I want to run a .sh file in Unix environment through servlet.
    Actually i want to do this inorder to schedule a report servet to run a report and generate the output in a particular format on a click of a button.
    I tried using Runtime.getRuntime().exec method, (which I know through forum is unreliable)
    Can anyone suggest me a method through I can achieve this?
    Any suggestion is appreciated.
    Regards,
    Rohan Kamat

    Hi MOD,
    Thanks for the quick reply.
    Heres what I am doing to schedule.
    1) The client selects the necessary parameters from the front end and then saves it in a table.
    2) This he will be doing for as many reports as he wants, on an average there will be 200 reports daily.
    3) Once he has selected all the parameters for all the reports, he will go to the next screen and fire a script to run the reports at a time.
    4) This script will be fired only once. And once it is fired it will generate a PDF files of the reports.
    5) On the front end the screen will be refreshed showing the users the status of the reports that he has scheduled to be run
    I am using Servlets 2.0 version, and jdk.12
    Regards,
    Rohan Kamat

  • Deleteing Session through ABAP Program

    Hi,
    I want to delete a session through a custom Program.
    Can anybody help me on how can I do it through An abap program.
    I want to get the same functionality which we do through
    SM04 and not SM12.
    for. eg. I want  that program should take the userid and
    and find how many sessions are open for him and delete the required session.
    Please help.
    Thanks
    GT

    You can do this like this :
    call function 'TH_DELETE_USER'
            exporting client = client
                      user   = user
                      tid    = tid
                      only_pooled_user = only_pooled_user

  • Record multiple, simultaneous sessions through one webinar meeting room

    Is there a way to record multiple, simultaneous sessions through one webinar meeting room? I know breakout rooms can't be recorded, but is there another way to have users join a main webinar room, select a sub-room/session they're interested in, and then join that sub-session? We want to have four sessions happening at once and allow users to choose which they want to participate in. We'd also like to record the sessions. Thanks for any help you can provide.

    Use PPT, or a tool of your choice, to create a slide/object with links to each room. Then the user can click between the rooms as desired.
    You may want to use the ?launcher=false command at the end of the URLs to keep the individuals from having the add-in launched multiple times and in multiple rooms at the same time. This will keep the meetings in the individual's browser.

  • Working with markups through servlet

    Hello,
    There is several problems with using Autovue through servlet.
    Fabula:
    Servlet receives http request, connect to the vue server (vue servlet via ServerControl), load .dwg file into
    vuebean by vuebean.setFile(new DocID(fileName)) and load markup by simple calling markupbean.readMarkup(FileInputStream instance) method.
    I get a markup file name by parsing 'markups.map'. Servlet modifies markup by http request parameters (set new FillColor, for example) and saves markup file -
    markupbean.writeMarkup(FileOutputStream) - very simple process.
    Problems:
    1. After markup changing i need to open dwg with markup (in applet), but i don't know how i can to do this. jVue.openMarkup() doesn't work - i don't understand what parameters are needed.
    2. When markup open via jVue applet GUI, changed TextBox elements are not visible, but presents in markup items list.
    If TextBox is selected it becomes visible! If I change the text or position of TextBox, it will become visible (without selection). This situation applies only to TextBoxes.
    Any suggestions how I can load markups into GUI and fix visibility of TextBoxes after saving via FileOutputStream.

    Hello,
    May I point out some issues where you are implementing code that is not supported nor documented (and probably will not) and consequently help on those topics is not available
    1. I get a markup file name by parsing 'markups.map' -> not documented, not supported, could change on any release.
    2. markupbean.writeMarkup(FileOutputStream) -> where? local datastore is not documented, will need synching, writing to it directly not supported, could change on any release.
    Stating it as a simple action is probably not the best way to describe a over-complicated solution piggybacking on a closed (undocumented) implementation
    Hence my recommendation for an open and properly documented platform
    Perhaps you should have started by describing what you are trying to do
    If what you want to implement is to save markups with a predefined name, then your solution is an overkill (and goes in the wrong direction)
    If you would be kind enough to
    1. follow this forum's rules ie https://forums.oracle.com/forums/ann.jspa?annID=1527
    2. properly state what you are trying to implement in another thread, if possible as it will make search/review easier to the rest of the community
    3. Have a tittle that is descriptive enough
    4. is this solution required to work on a cluster (ie more than one AV server)?

Maybe you are looking for

  • What is backed up if you are using iTunes and Windows

    I am wondering what is backed up. Music can restore from iTunes but what about calendar and contacts and photos if they were manually created on the phone. Are they stored someplace during sync and then can be restored? Where might this info be store

  • My God ! What is an F:/ drive?

    It says invalid F:/ and then stops downloading every time i try to download Itunes 7.6 and now my ipod isn't working at all! That just shouldn't happen regardless! Help?

  • Implementing Objects in Oracle Forms

    Am preparing for my Forms exam and would really appreciate it if anybody knew where i could get online info/resource with examples on how to implement and manage objects in Oracle forms. Have downloaded 10g and the associated documentation about 200M

  • What is the right update for Lion OS X 10.7.5 ?Is it Lion OS X Mavericks or Lion OS X 10.8 and above?

    I bought a Macbook Air 11" in 2011. It is currently running Lion OS X 10.7.5. What is the right update for this ?Is it Lion OS X Mavericks or Lion OS X 10.8 and above?

  • Can I make Siri understand me more clearly?

    Often when I ask Siri questions she doesn't understand what I'm saying, as in like she thinks I said something else. Is there anyway to make her understand or hear me more clearly? I talk loud enough and don't slur my words so I don't understand what