Continuously send data to applet through servlet

Hi,
I'm trying to write a servlet that, once activated, will continuously send data back to a thread in the client. My problem is that the data isn't actually sent until the stream is closed. I'm hoping someone can point me in the right direction:
Servlet code:
public class testStream extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
int[] somedata = new int [1];
somedata [0] = 1000;
String contentType =
"application/x-java-serialized-object";
response.setContentType(contentType);
ObjectOutputStream out =
new ObjectOutputStream(response.getOutputStream());
while (true) {
try {
out.writeObject(somedata );
System.out.println("Sent " + somedata [0]);
somedata [0]++;
} catch(Exception ie) {}
out.flush();
Thread.yield();
public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
Applet side code:
* <P>
* Taken from Core Servlets and JavaServer Pages
* from Prentice Hall and Sun Microsystems Press,
* http://www.coreservlets.com/.
* &copy; 2000 Marty Hall; may be freely used or adapted.
public class testStream implements Runnable {
private boolean isDone = false;
private URL dataURL;
public testStream(String urlSuffix, URL currentPage) {
try {
// Only the URL suffix need be supplied, since
// the rest of the URL is derived from the current page.
String protocol = currentPage.getProtocol();
String host = currentPage.getHost();
int port = currentPage.getPort();
dataURL = new URL(protocol, host, port, urlSuffix);
Thread imageRetriever = new Thread(this);
imageRetriever.start();
} catch(MalformedURLException mfe) {
System.err.println("Bad URL");
isDone = true;
public void run() {
try {
retrieveImage();
} catch(IOException ioe) {
isDone = true; // will never get hit
public boolean isDone() {  // meaningless now with infinite loop
return(isDone);
private void retrieveImage() throws IOException {
URLConnection connection = dataURL.openConnection();
connection.setUseCaches(false);
connection.setDoInput(true);
connection.setDefaultUseCaches (false);
connection.setRequestProperty("Content-Type", "application/x-java-serialized-object");
ObjectInputStream in = null;
try {
in = new ObjectInputStream(connection.getInputStream());
} catch (Exception pe) { System.err.println(pe); }
while (true) {
// loop forever requesting data
try {
// The return type of readObject is Object, so
// I need a typecast to the actual type.
int[] someData = (int[]) in.readObject();
System.err.println(someData[0]);
} catch(ClassNotFoundException cnfe) {
System.err.println("received NULL");
Thread.yield();

The original example was based on HTTP. I suppose yours is too. The HTTP protocol is for sending and receiving packets of finite length, and that is not your requirement. So don't use HTTP. Probably socket communications would be your best bet.

Similar Messages

  • Sending different types of data from applet to servlet

    Hi,
    I am writing an applet that uploads a file to a servlet. I can send the file to the servlet just fine.
    Applet Side
    1. open a URLConnection
    2. open a DataOutputStream
    3. write the file to the DataOutputStream
    Servlet Side:
    1. open a ServletInputStream from the HttpServletRequest
    2. write the bytes to a file
    This is all fine.
    However, I need to upload the filename (a String) with the file. How do I do this? I can't send the filename over as a String from the applet using the same DataOutputStream. right? This would corrupt the file that i am sending as the servlet wouldn't know that the difference between the filename and the actual contents of the file.
    Is there some property I can set in the urlconnection that gets passed to the request variable? i.e. URLConnection.setProperty ("filename", foo.txt) and then on the servlet side do this: String filename = eq.getProperty ("filename")
    Thank you for the help

    If all the additional data you want to send to server are textual or numaric data about the file (which is in the body of the request)
    Use those information as additional http headers.
    And read those header information from the servlet request object at the server side
    ex:-
    URL u = new URL("your url");
    HttpURLConnection c = (HttpURLConnection)u.openConnection();
    c.addRequestProperty("x-application-file-name","name of the file");
    c.addRequestProperty("x-application-file-size","size of the file");
    //then open the stream and write the data to the request body
    //             At server side         //
    String name = request.getHeader("x-application-file-name");
    long size= Long.parseLong(request.getHeader("x-application-file-size"));

  • Send data from applet to web server

    Hi,
    I want to send data(event notification) to resource through web server using url.
    Like,As long as perticular action or event is occuring I am sending that message to url.
    I reffered Sevlet theory uses HTTPMessage,but I am confused how should start and what would be feasible?
    Even when I run my code I am not finding browser.How should I place an applet in web server page?
    Regards,
    Palak
    Message was edited by:
    palak_shah

    Hi
    I agree usage of HttpClient is a better and a simple method.
    But If your Application Requirements are Simple you may go by using URL & URLconnection Objects in java.net package.
    Just to Add In You Can Checkout the links given below to have a better understanding of how the communication works...
    The Example APPLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.java.txt
    The Example SERVLET code:
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgServlet.java.txt
    and the Example AppletDemo Class
    http://mindy.cs.bham.ac.uk/AppletServletExample/EgApplet.class
    Hope this helps :)
    REGARDS,
    RaHuL

  • Problem in sending image from applet to servlet

    dear friends,
    i have a need to send an image from applet to servlet via HttpConnection and getting back that image from applet.
    i am struggling with this sice many hours and got tired by searching any post that would help me but haven't got yet.
    i tried using this code but it dosent make any execution sit right. i got NPE at ImageIcon.getDescription() line;
    at applet side
          jf.setContentPane(getJContentPane());
                     FileDialog fd=new FileDialog(jf,"hi");
                     fd.setMode(FileDialog.LOAD);
                     fd.setVisible(true);   
                     v=new Vector();
                     try{                                                
                               FileInputStream fis=new FileInputStream(new File(fd.getDirectory()+fd.getFile()));      
                               byte[] imgbuffer=new byte[fis.available()];
                               fis.read(imgbuffer);
                               ImageIcon imgdata=new ImageIcon(imgbuffer);
                               v.add(0,imgicon);
                                String strwp ="/UASProject/Storeimage";              
                                URL servletURL = new URL(getCodeBase(),strwp);             
                                HttpURLConnection servletCon = (HttpURLConnection)servletURL.openConnection();       
                                servletCon.setDoInput(true); 
                                servletCon.setDoOutput(true);
                                servletCon.setUseCaches(false);
                                servletCon.setDefaultUseCaches(false);   
                                servletCon.setRequestMethod("POST");     
                                servletCon.setRequestProperty("Content-Type", "application/octet-stream");   
                                servletCon.connect();            
                                ObjectOutputStream oboutStream = new ObjectOutputStream(servletCon.getOutputStream());                     
                                oboutStream.writeObject(v);
                                v.remove(0);
                                oboutStream.flush();      
                                oboutStream.close();  
                                //read back from servlet
                                ObjectInputStream inputStream = new ObjectInputStream(servletCon.getInputStream());
                                 v= (Vector)inputStream.readObject();                     
                                 imgicon=(ImageIcon)v.get(1);
                                 showimg.setIcon(imgicon);
                                 this.getContentPane().validate();
                                 this.validate();  
                                inputStream.close();                                                        
                             //  repaint();
                     }catch(Exception e){e.printStackTrace();}  and this is at servlet side
            try {       
                         Vector v=new Vector();                    
                         ObjectInputStream inputFromjsp = new ObjectInputStream(request.getInputStream());                                      
                          v = (Vector)inputFromjsp.readObject();                                                                                                          
                          imgicon=(ImageIcon)v.get(0);                     
                          inputFromjsp.close();            
                          System.out.println(imgicon.getDescription());                                      
                          v.remove(0);
                          v.add(1,imgicon);
    //sending back to applet
                           response.setContentType("application/octet-stream");
                          ObjectOutputStream oboutstream=new ObjectOutputStream(response.getOutputStream());            
                          oboutstream.writeObject(v);
                          oboutstream.flush();
                          oboutstream.close();
                   } catch (Exception e) {e.printStackTrace();}  i really need your help. please let me out of this headche
    thanks
    Edited by: san_4u on Nov 24, 2007 1:00 PM

    BalusC wrote:
    san_4u wrote:
    how can i made a HttpClient PostMethod using java applets? as i have experience making request using HttpURLConnection.POST method. ok first of all i am going make a search of this only after i will tell. please be onlineOnce again, see link [3] in my first reply of your former topic.
    yeah! i got the related topic at http://www.theserverside.com/tt/articles/article.tss?l=HttpClient_FileUpload. please look it, i am reading it right now and expecting to be reliable for me.
    well what i got, when request made by html code(stated above) then all the form fields and file data mixed as binary data and available in HttpServletRequest.getinputstream. and at servlet side we have to use a mutipart parser of DiskFileItemFactory class that automatically parse the file data and return a FileItem object cotaing the actual file data,right?.You can also setup the MultipartFilter in your environment and don't >care about it further. Uploaded files will be available as request attributes in the servlet.is the multipartfilter class file available in jar files(that u suggested to add in yours article) so that i can use it directly? one more thing the import org.apache.commons.httpclient package is not available in these jar files, so where can got it from?
    one mere question..
    i looked somewhere that when we request for a file from webserver using web browser then there is a server that process our request and after retrieving that file from database it sends back as response.
    now i confused that, wheather these webservers are like apache tomcat, IBM's webspher etc those processes these request or there is a unique server that always turned on and process all the request?
    because, suppose in an orgnisation made it's website using its own server then, in fact, all the time it will not turned on its server or yes it will? and a user can make a search for kind of information about this orgnisation at any time.
    hopes, you will have understand my quary, then please let me know the actual process
    thanks
    Edited by: san_4u on Nov 25, 2007 11:25 AM

  • 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

  • Sending data from applet to jsp

    hi all....
    i m very new in java so please and please spend ur few movement for this topic.
    i want to run a jsp page from within an applet and evantually want to send data to jsp.
    the data is an array of string object or may be a properties object,
    say String[] strarry={stringdata},or Properties props={setofkeysandvalues}
    the url of the jsp is http://8084/UASProject/Registrationform.jsp
    i have copied a code snippet from a topic posted in this forum.
    now please where should i formate in the code below to achieve this?
        try{
            URL appletURL = getCodeBase();
            String strHost = appletURL.getHost();
            String strPort = String.valueOf(appletURL.getPort());
            String strProtocol = appletURL.getProtocol();
            int portNumber = Integer.parseInt(strPort);
            String strwp ="/UASProject/Registrationform.jsp";
            //TCP port;
            URL jspURL = new URL(strProtocol,strHost,portNumber,strwp);
            URLConnection jspCon = jspURL.openConnection();
            jspCon.setUseCaches(false);
            jspCon.setDoOutput(true);
            jspCon.setDoInput(true);
            //jspCon.set
            ByteArrayOutputStream byteStream = new ByteArrayOutputStream(512);
            PrintWriter out = new PrintWriter(byteStream,true);
           // String postData= "?xmlText=" + URLEncoder.encode(genXml(),"UTF-8");
            //out.print(postData);
            out.flush();
            String strLength = String.valueOf(byteStream);
            jspCon.setRequestProperty("Content-Length",strLength);
            jspCon.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
            byteStream.writeTo(jspCon.getOutputStream());
            URL tempURL = new URL(String.valueOf(jspURL));
            getAppletContext().showDocument(tempURL);
        }catch(Exception e)   {}please explain the line String postData= "?xmlText=" URLEncoder.encode(genXml(),"UTF-8");+ why it is written for??

    angilna_loves_java wrote:
    hi all....
    i m very new in java so please and please spend ur few movement for this topic.Huh?
    i want to run a jsp page from within an applet and evantually want to send data to jsp.Oh good lord, why?!
    the data is an array of string object or may be a properties object,
    say String[] strarry={stringdata},or Properties props={setofkeysandvalues}
    the url of the jsp is http://8084/UASProject/Registrationform.jsp
    i have copied a code snippet from a topic posted in this forum.
    now please where should i formate in the code below to achieve this?I recommend you get a better grasp on Java and JSP before you go any further. I'm not clear on what problem you're having or what error your getting either.
    >
    try{
    URL appletURL = getCodeBase();
    String strHost = appletURL.getHost();
    String strPort = String.valueOf(appletURL.getPort());
    String strProtocol = appletURL.getProtocol();
    int portNumber = Integer.parseInt(strPort);
    String strwp ="/UASProject/Registrationform.jsp";
    //TCP port;
    URL jspURL = new URL(strProtocol,strHost,portNumber,strwp);
    URLConnection jspCon = jspURL.openConnection();
    jspCon.setUseCaches(false);
    jspCon.setDoOutput(true);
    jspCon.setDoInput(true);
    //jspCon.set
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream(512);
    PrintWriter out = new PrintWriter(byteStream,true);
    // String postData= "?xmlText=" + URLEncoder.encode(genXml(),"UTF-8");
    //out.print(postData);
    out.flush();
    String strLength = String.valueOf(byteStream);
    jspCon.setRequestProperty("Content-Length",strLength);
    jspCon.setRequestProperty("Content-Type","application/x-www-form-urlencoded");
    byteStream.writeTo(jspCon.getOutputStream());
    URL tempURL = new URL(String.valueOf(jspURL));
    getAppletContext().showDocument(tempURL);
    }catch(Exception e)   {}please explain the line String postData= "?xmlText=" URLEncoder.encode(genXml(),"UTF-8");+ why it is written for??Please read the API docs if you don't know what a particular method in Java does.

  • Send data from doPost() in servlet to AJAX

    Hi
    I need to send data from my servlet to my html(which contains AJAX), so as per the motivation of the AJAX, this should be done without my webpage reloading / refresh.
    my code on the ajax side is something like this:
    var xmlHttp = false;
    function getXMLHttpRequest(val) {
        try{
             xmlHttp = new XMLHttpRequest();
        }catch(err1){
            try{
                 xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            catch(err2){
                try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");}
                catch(err3){ request = null;}
        if (xmlHttp == false) {
            alert("Error creating request object !!");
        else if(xmlHttp != false){
            return xmlHttp;
    var xmlhttp = new getXMLObject();
    function ajaxFunction() {
           if(xmlHttp) {
            var value1 = document.getElementById("value1");
            xmlHttp.open("POST","ajax_controlller",true); //getname will be the servlet name
            xmlHttp.onreadystatechange  = handleServerResponse;
            xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
            xmlHttp.send("value1=" + value1.value); //Posting txtname to Servlet
    function handleServerResponse() {
         if (xmlHttp.readyState == 4) {
              if(xmlHttp.status == 200) {
    //            document.myForm.message.innerHTML=xmlHttp.responseText;
                alert(xmlHttp.responseText); //Update the HTML Form element
              else {
                 alert("Error during AJAX call. Please try again");
         }and the servlet (doPost()) looks like this :
                  if(request.getParameter("value1") != null){
                   value = request.getParameter("value1");
              else 
                   value = "";
              response.setContentType("text/html");
              response.getWriter().write("helllo");I however, do not understand what is wrong, do I need to specify the name of the html file just like we do in case of RequestDispatcher() methods. I dont think that is the case here ?

    The problem is: My value is passed correctly from my HTML(ajax) file to the servlet but I am not able to send the result(or data) from the servlet to the HTML (ajax) file, I know I can do this easily by session management but I need to establish this without the session management , In the servlet I use
    response.setContentType("text/html");          
    response.getWriter().write("helllo");
    and in the HTML file I use
    function handleServerResponse() {
         if (xmlHttp.readyState == 4) {
              if(xmlHttp.status == 200) {
                alert(xmlHttp.responseText); //Update the HTML Form element
              else {
                 alert("Error during AJAX call. Please try again");
            }so as per the logic I should get the alert as the result sent by the servlet on the same html page, but instead the servlet writes the hello on the new page, the URL of this page is the address of the servlet itself, so I conclude that I am not able to establish the connection between the servlet and the html file. Could you clarify this please ?

  • Problem in sending data to BW through XI

    Hi all,
    I am using "How to..push data to BW from XI".
    There a javascript code is given for sending data to BW using XI.
    But when I use that code for sending XML file it is showing a java script error:"Automation server can't create object".
    I think it has something to do with ADODB.Stream object.
    As given in the microsoft document I have deleted the registry entry which disables ActiveX component ADODB.Stream object.
    Even then it is showing the same error.
    Can someone figure out what is the problem.
    Any help will be appreciated.
    Regards,
    Anand

    Hi Anand,
            Sure, first i tried to send hardcoded data by using a report in bw, and refering the classes from transaction sproxy.
    The code was:
    REPORT  ZZ_TEST_XI_POC.
    *& Report  ZZ_TEST_XI_POC
    *& start of code by Anirban Ghatak , 14/03/06
    *& This Report will send data to sap xi
    *& start of code by Anirban Ghatak , 14/03/06
    DATA prxy TYPE REF TO ZPUSHCO_PROXY_INTERFACE_OB.
    CREATE OBJECT prxy.
    DATA it TYPE  ZPUSHPUSH_TABLE1.
    TRY.
        it-PUSH_TABLE-EMP_NO = 'Anirban'.
        it-PUSH_TABLE-EMP_NAME = '393'.
        it-PUSH_TABLE-DEPARTMENT_NAME = 'NetWeaver'.
        CALL METHOD prxy->execute_asynchronous
          EXPORTING
            output = it.
         commit work.
      CATCH cx_ai_system_fault .
        DATA fault TYPE REF TO cx_ai_system_fault .
        CREATE OBJECT fault.
        WRITE :/ fault->errortext.
    ENDTRY.
    *& End of code by Anirban Ghatak , 14/03/06
    then execute it , this sends data to xi.
    Refer /people/ravikumar.allampallam/blog/2005/03/14/abap-proxies-in-xiclient-proxy
    this can send data from bw to xi.
    Try have a look and see if you can replicate, actually mine is a POC so i have a little bit of flexibility but if you are working on a live devlopement reconsider the solution.
    Anirban.

  • Send data from bean to servlet and get results back to bean

    Hi,
    I'm new to this helpful forum and, as long as I'm practicing with JFS and Java Beans and Servlets, I really need some help about the following crappy issue.
    I made a JSP login page called "LoginPage.jsp" (using "Visual Web JSF Page" tool in NetBeans 6.0), and the action associated to the "Login" button pression is defined in the associated Java Bean "LoginPage.java":
    Code from "LoginPage.jsp":
    <webuijsf:button actionExpression="#{LoginPage.loginButton_action}" binding="#{LoginPage.loginButton}" id="loginButton" primary="true" style="height: 24px; left: 383px; top: 192px; position: absolute; width: 96px" text="Login"/>
    Code from "LoginPage.java":
    public String loginButton_action()
        if (usernameField.equals("guest") && passwordField.equals("guest")) // this control should be done by a servlet, not here!
            return "loginOK"; // this is the outcome for faces-config.xml that will lead to a "Welcome.jsp" page
        else
            return "loginERROR"; // this is the outcome for faces-config.xml that will lead to a "Error.jsp" page
    ...Now, the problem is that the username and password control should not be done by the bean itself, but by a servlet (call it "LoginServlet.java").
    In a few words, what I mean is that once the user writes username and password and presses the "Login" button, the called "loginButton_action()" forwards all the needed data to the servlet "LoginServlet.java", the servlet does the complete checks about login validity then prepares the result (it could be a string reporting "OK" or whatever else) and send it back to the bean "LoginPage.java", so that the flow can continue.
    My problem is that I absolutely don't know how to make a bean and a servlet communicate in both ways and respectively exchange data.
    Thanks in advance for any help, it will really be appreciated.

    Google for passing values in request and session.

  • Send email from j2me through servlet

    Hi people,
    i hope you can help me because i am new in network programming.
    I am trying to send email from j2me to googlemail account I have 2 classes EmailMidlet (which has been tested with wireless Toolkit 2.5.2 and it works) and the second class is the servlet-class named EmailServlet:
    when i call the EmailServlet, i get on the console:
    Server: 220 mx.google.com ESMTP g28sm19313024fkg.21
    Server: 250 mx.google.com at your service
    this is the code of my EmailServlet
    import java.io.*;
    import java.net.Socket;
    import java.net.UnknownHostException;
    import java.text.*;
    import java.util.Date;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class EmailServlet extends HttpServlet {
       public void doPost(HttpServletRequest request, HttpServletResponse response)
             throws IOException, ServletException {
          System.out.println("____emailservlet.doPost");
          response.setContentType("text/plain");
          PrintWriter out = response.getWriter();
          System.out.println("______________________________");
          out.println();
          String to = request.getParameter("to");
          System.out.println("____________________________to" + to);
          String subject = request.getParameter("subject");
          String msg = request.getParameter("msg");
          // construct an instance of EmailSender
          System.out.println("servlet_to" + to);
          send("[email protected]", to, subject, msg);
          out.println("mail sent....");
       public void send(String from, String to, String subject, String msg) {
          Socket smtpSocket = null;
          DataOutputStream os = null;
          DataInputStream is = null;
          try {
             smtpSocket = new Socket("smtp.googlemail.com", 25);
             os = new DataOutputStream(smtpSocket.getOutputStream());
             is = new DataInputStream(smtpSocket.getInputStream());
          } catch (UnknownHostException e) {
             System.err.println("Don't know about host: hostname");
          } catch (IOException e) {
             System.err
                   .println("Couldn't get I/O for the connection to: hostname");
          if (smtpSocket != null && os != null && is != null) {
             try {
                os.writeBytes("HELO there" + "\r\n");
                os.writeBytes("MAIL FROM: " + from + "\r\n");
                os.writeBytes("RCPT TO: " + to + "\r\n");
                os.writeBytes("DATA\r\n");
                os.writeBytes("Date: " + new Date() + "\r\n"); // stamp the msg
                                                    // with date
                os.writeBytes("From: " + from + "\r\n");
                os.writeBytes("To: " + to + "\r\n");
                os.writeBytes("Subject: " + subject + "\r\n");
                os.writeBytes(msg + "\r\n"); // message body
                os.writeBytes(".\r\n");
                os.writeBytes("QUIT\r\n");
                // debugging
                String responseLine;
                while ((responseLine = is.readLine()) != null) {
                   System.out.println("Server: " + responseLine);
                   if (responseLine.indexOf("delivery") != -1) {
                      break;
                os.close();
                is.close();
                smtpSocket.close();
             } catch (UnknownHostException e) {
                System.err.println("Trying to connect to unknown host: " + e);
             } catch (IOException e) {
                System.err.println("IOException: " + e);
       } 1.when i print "to" in EmailServlet also:
      String to = request.getParameter("to");
          System.out.println("____________________________to" + to);  it show null on the console :confused:
    2. ist this right in case of googlemail.com?
      smtpSocket = new Socket("smtp.googlemail.com", 25);  I would be very grateful if somebody can help me.

    jackofall
    Please don't post in old threads that are long dead. When you have a question, please start a topic of your own. Feel free to provide a link to an old thread if relevant.
    I'm locking this thread now.
    db

  • Send data Over Internet through SQL database .

    Hey I am using VB to developing my Windows Phone Application. I have to send my data generating from my App to a Online Database.
    I have domain , so C Panel, there I have database.
    can Any one suggest me the VB code for it?
    Or suggest me the link for it.
    Also please check out this http://1drv.ms/1E99miA Vishwa Raj ( Computer Hobbyist) Content Creator at Microsoft Community Center Web Developer at Sanity Softwares Pvt. Ltd Beginners in Windows Phone App Development.

    You cannot access a SQL Server Database from Windows Store App directly. You have to create a service layer (e.g a WCF service) that communicates with the database and then access this service from your app. There is a an example available here:
    https://code.msdn.microsoft.com/windowsapps/How-to-access-data-from-5f2602ec.
    ...and here:
    http://www.c-sharpcorner.com/UploadFile/7e39ca/connect-windows-store-apps-to-sql-server-database-using-wcf/.
    The samples are written in C# but you should get the idea. If you need help with converting certain parts of the code you could use an online calculator such as this one:
    http://converter.telerik.com/
    Or if you have some VB specific problem you could also start a new thread in the Visual Basic forum:
    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vbgeneral
    Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't post several questions in the same thread. 

  • Sending Cookie to JSP Through Servlet

    I am trying to read a cookie through JSP and cookie is defined in Servlet.
    Here is what happening?
    First JSP, user click on a hyperlink to select a category and that invokes servlet. Servlet has to pass selected category to another JSP page through a cookie.
    Here is the code for Servlet
    Cookie c1 = new Cookie("selectedCatgId", catgId);
    response.addCookie(c1);
    Target is a JSP, which I am calling through
    RequestDispatcher dispatcher;
    dispatcher = request.getRequestDispatcher("target.jsp");
    In target.jsp, when I am reading the Cookie
    Cookie cookies[] = request.getCookies();
    Cookie currCookie;
    if (cookies != null) {
    for (int i=0; i<cookies.length; i++) {
    currCookie = cookies;
    if (currCookie.getName().equals("selectedCatgId")) {
    parentCatgId = currCookie.getValue();
    This shows me one previous value of the cookie, not the current value I passed through the servlet. Not what I set in servlet.
    Can anybody help in this? I am not sure where I am wrong?
    Thanks, Vikas

    You are passing information on the server side. So, you should use attributes and not cookies.
    Also, take a look:
    Cookie c1 = new Cookie("selectedCatgId", catgId);
    response.addCookie(c1); //here you added a new cookie that has not been sent to the client yet
    RequestDispatcher dispatcher;
    dispatcher = request.getRequestDispatcher("target.jsp"); //Here you called a new JSP page. A server side operation.
    Cookie cookies[] = request.getCookies(); //Here you are reading a cookie sent by the client. But the c1 has not been sent to the client yet. So you didnt get this cookie on the request.

  • Send Data from Applet to Application

    Hi,
    can anybody give me a hint on how to exchange data between a java-applet and a java-application running on the same machine?
    thanx

    Microsoft IIS and SQL Server 2000 can be made to handle HTTP-based SQL queries and return results in XML format.
    Personally, I would far rather a solution (unless specifically developed for a single client bent on Microsoft technology) require some form of Java-database interaction on the server side, which ultimately can be made to work with MS-SQL, mySQL, Oracle or whatever, than be tied into Microsoft technologies and hence require an existing MS infrastructure or budget to create one.
    But that's just me!

  • Getting error while sending data to OIM through SPMLWS

    [11/12/10 4:12:29:834 EST] 00000040 SystemOut O ERROR,12 Nov 2010 04:12:29,830,[XELLERATE.ACCOUNTMANAGEMENT],Class/Method: tcUtilityFactory/getPropertyValue encounter some problems: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
    java.lang.ClassCastException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.ibm.rmi.javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:372)
         at javax.rmi.PortableRemoteObject.narrow(PortableRemoteObject.java:137)
         at com.thortech.xl.ejb.interfaces.tcUnauthenticatedOperationsUtil.lookupHome(Unknown Source)
         at com.thortech.xl.ejb.interfaces.tcUnauthenticatedOperationsUtil.getHome(Unknown Source)
         at Thor.API.tcUtilityFactory.getUnauthenticatedOperations(Unknown Source)
         at Thor.API.tcUtilityFactory.getPropertyValue(Unknown Source)
         at Thor.API.tcUtilityFactory.<init>(Unknown Source)
         at com.oracle.xl.spmlws.oim.eventhandler.OIMCallFactory.<init>(Unknown Source)
         at com.oracle.xl.spmlws.framework.eventhandler.OIMEventHandler.handleRequest(Unknown Source)
         at com.oracle.xl.spmlws.framework.event.EventMediator.executeEventHandlerSequence(Unknown Source)
         at com.oracle.xl.spmlws.framework.event.EventMediator.processEvent(Unknown Source)
         at com.oracle.xl.spmlws.framework.engine.Engine.process(Unknown Source)
         at com.oracle.xl.spmlws.framework.engine.Engine.provision(Unknown Source)
         at com.oracle.xl.spmlws.ws.server.websphere.HttpSoap11BindingImpl.processRequest(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:178)
         at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:141)
         at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:453)
         at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:414)
         at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
         at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:152)
         at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:336)
         at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:831)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1075)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:550)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
         at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3391)
         at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
         at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:115)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:556)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:606)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:979)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1064)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
    [11/12/10 4:12:29:857 EST] 00000040 SystemOut O ERROR,12 Nov 2010 04:12:29,856,[SPMLWS.ENGINE],Provisioning Failed
    [11/12/10 4:12:29:863 EST] 00000040 SystemOut O ERROR,12 Nov 2010 04:12:29,857,[ EXCEPTION WHILE PROCESSING PAYLOAD ],SPMLWS.Utility
    com.oracle.xl.spmlws.framework.engine.EngineException: com.oracle.xl.spmlws.framework.engine.EngineException: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.oim.eventhandler.OIMEventException: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.oracle.xl.spmlws.framework.engine.Engine.provision(Unknown Source)
         at com.oracle.xl.spmlws.ws.server.websphere.HttpSoap11BindingImpl.processRequest(Unknown Source)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:585)
         at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeMethod(JavaDispatcher.java:178)
         at com.ibm.ws.webservices.engine.dispatchers.java.JavaDispatcher.invokeOperation(JavaDispatcher.java:141)
         at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processRequestResponse(SoapRPCProcessor.java:453)
         at com.ibm.ws.webservices.engine.dispatchers.SoapRPCProcessor.processMessage(SoapRPCProcessor.java:414)
         at com.ibm.ws.webservices.engine.dispatchers.BasicDispatcher.processMessage(BasicDispatcher.java:134)
         at com.ibm.ws.webservices.engine.dispatchers.java.SessionDispatcher.invoke(SessionDispatcher.java:204)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.handlers.jaxrpc.JAXRPCHandler.invoke(JAXRPCHandler.java:152)
         at com.ibm.ws.webservices.engine.handlers.WrappedHandler.invoke(WrappedHandler.java:64)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.PivotHandlerWrapper.invoke(PivotHandlerWrapper.java:228)
         at com.ibm.ws.webservices.engine.WebServicesEngine.invoke(WebServicesEngine.java:336)
         at com.ibm.ws.webservices.engine.transport.http.WebServicesServlet.doPost(WebServicesServlet.java:831)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
         at com.ibm.ws.webservices.engine.transport.http.WebServicesServletBase.service(WebServicesServletBase.java:341)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1075)
         at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:550)
         at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:478)
         at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3391)
         at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:267)
         at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:811)
         at com.ibm.ws.wswebcontainer.WebContainer.handleRequest(WebContainer.java:1455)
         at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:115)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:458)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:387)
         at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:267)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
         at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java:556)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java:606)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java:979)
         at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java:1064)
         at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1473)
    Caused by: com.oracle.xl.spmlws.framework.engine.EngineException: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.oim.eventhandler.OIMEventException: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.oracle.xl.spmlws.framework.engine.Engine.process(Unknown Source)
         ... 40 more
    Caused by: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.oim.eventhandler.OIMEventException: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.oracle.xl.spmlws.framework.event.EventMediator.processEvent(Unknown Source)
         ... 41 more
    Caused by: com.oracle.xl.spmlws.framework.event.EventException: com.oracle.xl.spmlws.oim.eventhandler.OIMEventException: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.oracle.xl.spmlws.framework.eventhandler.OIMEventHandler.handleRequest(Unknown Source)
         at com.oracle.xl.spmlws.framework.event.EventMediator.executeEventHandlerSequence(Unknown Source)
         ... 42 more
    Caused by: com.oracle.xl.spmlws.oim.eventhandler.OIMEventException: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at com.oracle.xl.spmlws.oim.eventhandler.OIMCallFactory.<init>(Unknown Source)
         ... 44 more
    Caused by: Thor.API.Exceptions.tcAPIException: Unable to load class: com.thortech.xl.ejb.interfaces._tcUnauthenticatedOperationsHome_Stub
         at Thor.API.tcUtilityFactory.getPropertyValue(Unknown Source)
         at Thor.API.tcUtilityFactory.<init>(Unknown Source)
         ... 45 more
    [11/12/10 4:12:29:918 EST] 00000040 SystemOut O DEBUG,12 Nov 2010 04:12:29,917,[ WEBSERVICE METHOD PROCESSREQUEST ENDS ],SPMLWS.Utility

    Follow these steps..
    http://download.oracle.com/docs/cd/E14899_01/doc.9102/e14764/toc.htm#BGBJIIID
    If you are using IBM WebSphere Application Server as the application server, then update the xlDataObjectBeans.jar file as follows:
    Note:
    Ensure that you perform these steps after you have performed the procedure described in "Upgrading Oracle Identity Manager on IBM WebSphere Application Server".
    1.
    In a Web browser, connect to the WebSphere administrative console by using a URL of the following format:
    http://HOST_NAME:PORT/admin
    2.
    Log in by using the Oracle Identity Manager administrator account that you specified during installation.
    3.
    Click Applications, and then select Enterprise Applications.
    4.
    Select Xellerate application.
    5.
    Click Export.
    6.
    Save the xellerate.ear file to a temporary directory.
    7.
    Extract the xlDataObjectBeans.jar file from the xellerate.ear file.
    Note:
    Ensure that you extract the xlDataObjectBeans.jar file and not the xlDataObjects.jar file.
    8.
    Copy the xlDataObjectBeans.jar file into the OIM_DC_HOME\xlclient\lib directory.

  • Whenever firefox is turned on it starts sending data, more data is being sent than i am recieving as downloads for opening websites

    when i open firefox, it starts sending data, it doesnt matter which website i open, it is continuously sending data, if i look at my wireless connection status on my laptop the packet counter for data sent is just clicking over non stop where as the packet counter for data received runs a lot slower.

    when i open firefox, it starts sending data, it doesnt matter which website i open, it is continuously sending data, if i look at my wireless connection status on my laptop the packet counter for data sent is just clicking over non stop where as the packet counter for data received runs a lot slower.

Maybe you are looking for

  • Receiver IDoc Adapter - Outbound IDocs in IDX5 but stucked in SM58

    Hi Gurus, I have a Receiver IDoc issue with the above error. My message is successful in the IE pipeline (but with error on outbound side) I can even view the generated IDoc numbers for those messages in IDX5,   but when double-clicking on those IDX5

  • Sometimes TB can't fetch messages

    For some time now, TB has sometimes been stopping receiving messages. This happens apparently randomly, like this morning. I was away from the keyboard for half an hour, came back and it had happened again. Suddenly TB was unable to connect with the

  • Error  in external table

    Suppose we have a file containing city populations in our /tmp directory and we wish to access this data from within our database. Tokyo,Japan,33600000 Seoul,South Korea,23400000 Mexico City,Mexico,22400000 New York,USA,21900000 Bombay,India,21600000

  • Need Help with simple array program!

    Hi, I have just recently started how to use arrays[] in Java and I'm a bit confused and need help designing a program. What this program does, it reads in a range of letters specified by the user. The user then enters the letters (a, b or c) and stor

  • OSX 10.4.11 & iTunes 7.5 Update recent feedback

    I have avoided taken both OSX 10.4.11 & iTunes 7.5 update - as it seems that some had issues and others didn't. Is there any further information out there on this? Just wondering who has taken the plunge and still has unresolved issues. Cheers Dee To