How to show progress - Applet - Servlet

Hi,
I am new to applet-servlet communication. I have to show the progress at the applet front-end using a JProgressBar for a task being done at the servlet end. I request the gurus on the forum to post any example code for the above situation.

Hi,
U will have to use the SwingWorker to popup the JProgressBar, but in here i dont think u will be getting any input from servlet giving the job completed, if u are using jdk1.4.1 u can use
setIndeterminate(true);
I am attaching 2 methods below which i use to display the JProgressBar
Method long task is where i actually call the servlet and in method buildData i create the URLConnection etc
//appletData must implement Serializable
public void buildData(Object appletData)throws Exception
//define servlet name here
ObjectInputStream inputFromServlet = null;
URL          studentDBservlet = new URL("MyServlet");
URLConnection servletConnection = studentDBservlet.openConnection();
servletConnection.setDoInput(true);
servletConnection.setDoOutput(true);
servletConnection.setUseCaches(false);
servletConnection.setRequestProperty("Content-Type", "application/octet-stream");
ObjectOutputStream outputToServlet =
          new ObjectOutputStream(servletConnection.getOutputStream());
     // serialize the object
     if (!SwingUtilities.isEventDispatchThread())
          outputToServlet.writeObject(input);
          outputToServlet.flush();
          outputToServlet.close();
          inputFromServlet = new ObjectInputStream(servletConnection.getInputStream());
     else
          inputFromServlet = longTask(servletConnection, outputToServlet, appletData);
private ObjectInputStream longTask(final URLConnection servletConnection,
                    final ObjectOutputStream outputToServlet,
                    final Object appletData)
     final JDialog dialog = new JDialog(PlanApplet.appletFrame, "Please Wait", true);
isProcess = true;
     MapsPanel panel = new MapsPanel();
     panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
     //MapsLabel label = new MapsLabel("Work in process....");
//label.setFont(Constant.bigFont);
     //label.setPreferredSize(new Dimension(230, 40));
     JProgressBar progressBar = new JProgressBar();
     progressBar.setIndeterminate(true);
     progressBar.setPreferredSize(new Dimension(140, 30));
// final JugglerLabel jugLabel = new JugglerLabel();
// jugLabel.startAnimation();
// panel.setPreferredSize(new Dimension(175, 175));
     MapsPanel progressPanel = new MapsPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
     progressPanel.setPreferredSize(new Dimension(140, 80));
progressPanel.add(progressBar);
//     progressPanel.add(jugLabel);
//     panel.add(Box.createVerticalStrut(5));
     //panel.add(label);
     panel.add(Box.createVerticalStrut(15));
     panel.add(progressPanel);
     panel.add(Box.createVerticalStrut(15));
     dialog.setSize(150, 115);
     dialog.setResizable(false);
//     dialog.getContentPane().add(jugLabel);
dialog.getContentPane().add(panel);
dialog.setDefaultCloseOperation(JDialog.DO_NOTHING_ON_CLOSE);
dialog.setLocation(ScreenSize.getDialogLocation(dialog));
//      final javax.swing.Timer popupTimer = new javax.swing.Timer(2000, new TimerListener(dialog));
     final SwingWorker worker = new SwingWorker()
     public Object construct()
          try
          PlanApplet.applet.setCursor(new Cursor(Cursor.WAIT_CURSOR));
          outputToServlet.writeObject(appletData);
          outputToServlet.flush();
          outputToServlet.close();
          return new ObjectInputStream(servletConnection.getInputStream());
          catch (Exception exc)
          return null;
     public void finished()
// jugLabel.stopAnimation();
          dialog.dispose();
Toolkit.getDefaultToolkit().beep();
isProcess = false;
          LogWriter.out("the long process is finished", LogWriter.BASIC);
     worker.start();
// popupTimer.start();
     //System.out.println("Process complete");
     dialog.show();
// while(isProcess)
     return (ObjectInputStream) worker.getValue();

Similar Messages

  • How to show progress bar in miniplayer?

    How to show progress bar in miniplayer? I play a lot of music podcasts and it would be very helpful if anyone could help me bring that feature back.

    i answered here:
    http://forum.java.sun.com/thread.jspa?messageID=9739423&#9739423

  • How to show progress bar

    how to show progress bar

    This gets asked about 100 times a day, especially when you get people posting it multiple times - learn to use the search facility, or at least Google. It's really not that hard.
    Type "java progress bar" into Google and hit "I'm feeling lucky" - the answer is there.

  • How to show progress bar in java???

    Hey guys!!! can any one tell me how to show the progress bar when a processing is going on???Is it done by multithreading?? I have to import data from database kept in another machine into my database.It would take quite a longer time especially when database is quite large.I want to show the progress and every data being imported to the user so that user does not think that system has hanged on...Please help...

    i answered here:
    http://forum.java.sun.com/thread.jspa?messageID=9739423&#9739423

  • How to show colors from servlet

    Greetings
    Please give me a example of how to show color baground and how to show buttons and list objects from servlets.
    Thanks in advance

    Here is the code sample:
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class ServletSample extends HttpServlet {
      public void service(HttpServletRequest request, HttpServletResponse response)
       throws ServletException, IOException {
        PrintWriter pw = response.getWriter();
        pw.println("<html>");
        pw.println("<head>");
        pw.println("</head>");
        //set background color   
        pw.println("<body bgcolor="#99cccc">");
        //list object?
        ServletContext context = getServletContext();
        pw.println(context.getRealPath("/."));
        //create a submit button   
        pw.println("<button type=\"submit\">A Submit Button</button>");
        pw.println("</body>");
        pw.println("</html>");
    }I recommand to take a tutorial or a book on Servlet

  • How to show progress during a long Render call

    My effect computes values from all frames in a layer much like Warp Stabilizer does. I set a flag and do this when necessary in my Render function. The user controls when to analyze by clicking a button in the effect UI.
    It can take from a few seconds to over a minute depending on the layer, so I need to show progress to the user.
    In After Effects I can use the progress bar, and put text in the info panel from within the Render proc; but I'd like to find a better way to show progress.
    Indicidentally, neither of these two thing seem to works in Premiere Pro.
    Warp Stabilizer shows progress to the left of the Analyze button in its effects window, but I can's seem to do this from within Render.
    Any ideas?

    Try the Top Menu or Menu button on the dvd player remote. That usually returns to the start of the dvd.

  • How to do Applet/Servlet permanent interactive connection

    Hi, I'm modifying an Instant Messaging Application originally implemented under the Applet client/standalone-server scheme that I'm implementing now under the Applet/Servlet scheme using HTTP Tunneling with Object Serialization. But this yet don't work correctly because the connection's flows are closed ever after a Servlet's response to a client request (in this moment are close the connection's flows). I'm using flows of type ObjectInputStream and ObjectOutputStream using Object Serialization with HTTP Tunneling.
    this is part of the connection code in the servlet side:
    public void doGet (HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException{
    doPost( request, response);
    public void doPost(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException{
    is = new ObjectInputStream(
    new BufferedInputStream(request.getInputStream()));
    try{  
    response.setStatus(HttpServletResponse.SC_OK);
    out = new ObjectOutputStream (
    new BufferedOutputStream (response.getOutputStream ()));
    out.writeObject("OK");
    out.flush();
    // Send the input and output flows to the Thread the Handle the client Connection
    newUser(is, out);
    } catch(Exception ex){
    System.err.println("Exc1: "+ex.toString());
    ex.printStackTrace();
    Run Method to read client request:
    public void run() {
    SocketData sd;
    while ((sd = readObject()) != null) {                               
    sd.performAction(this);
    close();
    After a servlet response in the readObject() method the input flow is closed in the reader request of clients and the connection between the applet (client) and servlet is lost.
    How to can implement a smarter HTTP Tunneling with permanent interactive connection beetween the Applet and Servlet such as in the Applet /server Standalone connection using TCP/IP Socket connection.
    Is possible the use of TCP/IP Sockets in the implementation of HTTP Tunneling with Object Serialization in the Applet/Servlet permanent interactive communication scheme?
    some links or code samples?
    Please show me the ligth.
    Thanks greatly a smarter help.

    I'm not sure that I fully understand your problem, but HTTP is a stateless protocol. That means request-response pairs are completely separated from each other.
    You should ask yourself if you really need to use HTTP and a servlet or if a raw TCP/IP communication would be a better approach to your problem.

  • How do you use the status column to show progress of a step in an OI?

    Hi everyone,
    I was just doing a little browsing and noticed the picture at the top of the http://www.ni.com/teststand/ web page.  It shows a progress bar in the status column of a step being executed.
    I have several applications where this would be a very useful addition.  I use the progress bar at the bottom of the OI and sequence editor regularly, but would very much like to show progress of an individual step in the status column.  It would be particularly useful where you turn the tracing off into a sequence but want to see that progress is being made through the steps within it...
    Anyone know how to do this?  I have been unsuccessful in trying to find examples....
    Cheers,
    Barry

    James,
    I believe your answer to Bazza's question also applies to my situation, but I wasn't sure so I thought I would ask.  I am working on a custom TestStand operator interface in LabVIEW using the UI controls.  I would like it to behave as closely as possible to the old Test Executive.  Specifically, I would like the operator to be able to see the contents of the sequence file, interact with them, and see the execution results all in the same view.  Is that possible?  In other words, can I display and interact with a sequence file (display the sequence steps, run selected steps, loop selected steps, etc.) and display the sequence's execution results (including tracing) in the same SequenceView control or do I have to use 2 of them?
    Thanks,
    Ryan Wright

  • How to create an applet that shows a pdf as non-editable.

    Hi friends,
    Does any one know how to create an applet that shows a pdf document (should make that pdf a non-editable one) while clicking a link.Its urgent for me as I have to complete this one tomorrow itself...please help me...
    I am able to view the pdf document but that cannot be make a non-editable one.
    Can anyone gave me the code for that one....please I am not very much good in Java.

    PDF is a proprietary format and Java doesn't support it by default. Are you using a 3rd party tool to create the PDF? If so, you need to review the developer docs to see how to make the document non-editable. Frankly, I don't see why you're using an Applet to view a PDF in the first place. What exactly are you trying to do. I'm confused.

  • Show progress bar before loading the applet or application

    hi ,
    My application size is large and take some time to load . Now i want that to show progress bar . how can i do this .Please Help me
    sorry for my english.
    Thanks

    Do everything in a seperate thread. Create a progress bar in the main thread, then create a new thread for initializing your app. Once the init is done, hide the progress bar and make your app visible.

  • How to show the shutdown progression of Solaris 10

    Hi,
    I am just wondering how to show shutdown progress of Solaris 10, the default messages on the console are too little.
    Thanks
    Bin

    i have tried to change /etc/default/init
    first of all it is read only fie.
    then this command /user/dt/bin/dtconfig -kill
    is command is not working.............
    is thr any other process to change the language.
    i have mistaken to chage my language to spanise.
    i want to revert back to english or default.

  • How to forward an applet page to servlet/jsp?

    I have an applet in imageMap.jsp file. This applet displays a map. When user enters the page of imageMap.jsp, they will see the map . If user clicks a point of the map, the latitude and longitude of that point should be sent to Search.java servlet and search results should replace the current page.
    My Search.java servlet works well.
    I think I should add mouse event in the applet. I can use MouseEvent.getX() and MouseEvent.getY() in the applet to get latitude and longitude. But I do not know how to go from this applet to servlet. How can I forward applet page to servlet?

    The <jsp:plugin> action is used in pages to generate client specific HTML tags involving download and execution of the applet that is specified in the tag.

  • How to show the progress bar on forms?

    Hello ALL,
    How should we show the progress bar in our forms screen so we can see how much work is remaining?
    For example if we are performing some task through forms, what code and on which trigger we placed this code in order to show the progress bar that inform us about the task in progress.
    Thanks
    malan

    Hi,
    Shouldn't the oracle forms' support the progress
    bar?
    I prefer to have a code which shows progress bar on
    forms.
    Can some one have this code ?
    ThanksPJC progress bars are shown on the form and forms support progress bar and coding itit's relatively easy.
    If I were you I would take Francois' advice and type in "progress bar" in the lil search box :)
    It's a wonder what a lil search can show you
    Tony

  • How to show the progress indicator

    Hi,
    I need to show progress indicator while search operation. Can any one help me how can i do this.

    Hi Shay,
    Thanks for your reply...
    i have implemented same thing into my application, but its not working properly. when i use Glasspanel into my application page is coming in small.
    Page:
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    xmlns:tr="http://myfaces.apache.org/trinidad"
    xmlns:trh="http://myfaces.apache.org/trinidad/html"
    xmlns:fns="/fnimphiu/sample">
    <jsp:directive.page contentType="text/html;charset=windows-1252"/>
    <f:view beforePhase="#{ESPSMenu.createMenus}">
    <af:document title="ESPS-Accounts Page" binding="#{backingBeanScope.backing_app_AccountsPage.document1}"
    id="ACCOUNTS">
    <af:messages binding="#{backingBeanScope.backing_app_AccountsPage.messages1}"
    id="messages1"/>
    <af:form binding="#{backingBeanScope.backing_app_AccountsPage.form1}"
    id="form1" >
    <af:pageTemplate viewId="/templates/ESPSTemplate.jspx" value="#{bindings.pageTemplateBinding}" id="pt1">
    <f:facet name="menu"/>
    <fns:GlassPane binding="#{backingBeanScope.backing_app_AccountsPage.gp1}"
    id="gp1" busytext="I am Busy" launchAction="#{backingBeanScope.backing_app_AccountsPage.glassAction}">
    <f:facet name="image">
    <af:image id="img1" source="/images/busy.gif" shortDesc="I am Busy"/>
    </f:facet>
    </fns:GlassPane>
    <af:panelGroupLayout layout="vertical"
    binding="#{backingBeanScope.backing_app_AccountsPage.panelGroupLayout8}"
    id="panelGroupLayout8">
    <af:panelHeader text="Accounts"
    binding="#{backingBeanScope.backing_app_AccountsPage.panelHeader61}"
    id="panelHeader61">
    <af:query id="qryId131" headerText="Search" disclosed="true"
    value="#{bindings.CmSubscriberNewViewCriteriaQuery.queryDescriptor}"
    model="#{bindings.CmSubscriberNewViewCriteriaQuery.queryModel}"
    queryListener="#{backingBeanScope.backing_app_AccountsPage.processQuery}"
    queryOperationListener="#{bindings.CmSubscriberNewViewCriteriaQuery.processQueryOperation}"
    binding="#{backingBeanScope.backing_app_AccountsPage.qryId131}"
    resultComponentId="::table22"
    rows="5" maxColumns="2"/>
    </af:panelHeader>
    </af:panelGroupLayout>
    Bean:
    public void glassAction(ClientEvent clientEvent) {
    // Add event code here...
    System.out.println("Inside glassAction");
    GlassPaneHelper.closeGlassPane();
    refreshCurrentPage();
    protected void refreshCurrentPage() {
    System.out.println("Inside refreshCurrentPage");
    FacesContext context = FacesContext.getCurrentInstance();
    System.out.println("Inside refreshCurrentPage context:"+context);
    String currentView = context.getViewRoot().getViewId();
    System.out.println("Inside refreshCurrentPage currentView:"+currentView);
    ViewHandler vh = context.getApplication().getViewHandler();
    System.out.println("Inside refreshCurrentPage vh:"+vh);
    UIViewRoot x = vh.createView(context, currentView);
    System.out.println("Inside refreshCurrentPage x:"+x);
    context.setViewRoot(x);
    public void processQuery(QueryEvent queryEvent) {
    System.out.println("Inside processQuery");
    GlassPaneHelper.openGlassPane();
    invokeMethodExpression( "#{bindings.CmSubscriberNewViewCriteriaQuery.processQuery}"
    , Object.class, QueryEvent.class, queryEvent);
    Help me how can i resolve this.

  • How to show an html page using JEditorPane in applet.

    I have never use jeditorpane with applet so i dont know how to show a html page.if you have some code or any example then please posted that.Thanks

    public class MyApplet extends JApplet{
        private JTextPane textPane = null;
        public void init(){
        HTMLEditorKit editorKit = new HTMLEditorKit();
        HTMLDocument  htmlDoc   = (HTMLDocument)editorKit.createDefaultDocument();
        textPane  = new JTextPane();
        textPane.setEditable(false);
        textPane.setEditorKit(editorKit);
        textPane.setContentType("text/html");
        textPane.setDocument(htmlDoc);
        Container c = getContentPane();
        c.add(new JScrollPane(textPane),    BorderLayout.CENTER);
        c.add(buttonPanel,                  BorderLayout.SOUTH);
        c.add(Box.createVerticalStrut(5),   BorderLayout.NORTH);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.EAST);     
        c.add(Box.createHorizontalStrut(5), BorderLayout.WEST);
        public void setHtml(String html){
            // you should check the textpane's document to detrmine if there
            // is already text in there..if so, then clear the textpane text and then
            // set the new html...Note: JTextPane only show basic Html ..
            // not like a full blown browser
            textPane.setTextt(html);
            textPane.setCaretPosition(0);
    }

Maybe you are looking for

  • JBO-26061: Error while opening JDBC connection, null password given; logon

    Dear all, i have this problem and am trying to solve it since 4 days and still the same the problem is when i create a new project every thing works fine but what happen is when i change the connection or create new Connection in the bc4j, this what

  • How do I remove a phone number from iMessage on my Mac?

    I get a new iPhone tomorrow on a completely new number and I wanted to know how I can remove my current number from being used for iMessage on my mac so that when I get my new phone I can set it up

  • Factoring a Goods Receipt Batch Value by 100

    In our scenario we are receiving material using Batch Specific Alternate Units of Measure.  The base uom of the material is LB and we've created a Batch Specific uom called GLB under No Dimensions   We have also configured a conversion ratio called L

  • How can I get alerted when someone replies to my comment?

    I would really like to get a notification when someone replies to my comment in the forums. I have set my preferences to get email notifications for things I'm following but I get notifications for every time someone writes something in the forums. (

  • Two tables of contact persons while typing text message.

    Hi, when I want to type a text message and when I try to type the name of the contact person. The blackberry shows the possibilities twice. So I see two tables of contact persons but just one is a workable table. The other stays as a kind of backgrou