Send arraylist to swings from servlet

Hi,
I send string to jsp from swings using URL(pass as a query string)
And then call servet from jsp(submit some values to this servlet from jsp)
Now i want to send ArrayList to my swings ,
How it is,
i know call servlet from swings,retrive values from servlet to swings. This is two way communication,
But now my requirement is one way, i didn't call servlet directly from swings, i call from jsp
Help me,
Thanks in advance

Thanks for reply
i write code in my swing as
ArrayList pdetails;
URL url=new URL(getCodeBase()+"sample.jsp");
            URLConnection con =url.openConnection();
            con.setDoInput(true);
            con.setDoOutput(true);
            con.setUseCaches(false);
            OutputStream outstream = con.getOutputStream();
            ObjectOutputStream oos = new ObjectOutputStream(outstream);
            oos.writeObject(pdetails);
            oos.flush();
            oos.close();
            AppletContext context=getAppletContext();
            context.showDocument(url,"_blank");my jsp code is
<%@page import="java.io.*,java.util.*"%>
<%
ObjectInputStream inputFromApplet = null;
ArrayList transmitContent =null;
inputFromApplet = new ObjectInputStream(request.getInputStream());
System.out.println(inputFromApplet);
transmitContent = (ArrayList) inputFromApplet.readObject();
out.println(transmitContent);
%>
but i got an exception like this21:28:50,078 WARN [[jsp]] Servlet.service() for servlet jsp threw exception
java.io.EOFException
at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream
.java:2232)
at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputS
tream.java:2698)
at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:750
at java.io.ObjectInputStream.<init>(ObjectInputStream.java:268)
at org.apache.jsp.sample_jsp._jspService(org.apache.jsp.sample_jsp:52)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper
.java:322)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:3
14)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
lter.java:96)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:202)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:178)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrinc
ipalValve.java:54)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
yAssociationValve.java:174)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
e.java:74)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
a:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p
rocessConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpo
int.java:527)
at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWor
kerThread.java:112)
at java.lang.Thread.run(Thread.java:595)

Similar Messages

  • How to send a String value  from Servlet to  Action class in Struts .

    when iam trying to send string value from Servlet to Struts Action class through Http Session, iam getting null value, iam really in big confusion, help me.

    please elaborate clearly or put you code of both action and servlet here
    Are both of them in same web application

  • Sending Response to xsl from servlet

    Hi,
    I am submitting request from xsl file to servlet through form,this action is taking place properly,but i want o return some rsult from servlet to xsl file. can any body tell me how to do this.
    Thanks in advance

    Put the results into the request scope, then forward the page to the JSP, which takes the results from the request scope and displays it.

  • Passing XML payload from Servlet to JMS

    Hi All,
    My requirement is that servlet will receive the HTTP request , convert it into XML format and publish it to JMS queue.
    Now, I am stuck at the part where I need to publish the XML payload to JMS queue.
    Is it possible to send the XML payload from servlet to JMS queue? Is yes, please let me know how can we achieve this.
    Thanks

    I suggest you go to the following page: [http://edocs.bea.com/wls/docs103/pdf.html] .
    In the "Programming" section, download and read at least "Programming WebLogic JMS" and perhaps "Developing Web Applications, Servlets, and JSPs for WebLogic Server" and "Developing Applications with WebLogic Server".

  • How to send a message from Servlet to JSP

    Dear all,
    I have JSP, with JavaScript (AJAX). If the user click on the button, the text will be sent to a Servlet parsed by doGet() and the user get a response to his input, without reloading a page.
    How can I send a message to the users (JSP) from Servlet, if he didn't clicked any button and to other visitor of the page also? Is it possible? I think like a chat, the server sends a message to all users who are subscribed.
    I don't know, what should I get from user, maybe session, that I could send him personal or common messages in his textarea. I should also invoke some JavaScript function to update his page. I have met some chats, you don't do nothing and get messages. It is also without a JavaScript timer, which invokes doGet() method. Asynchronous, only when there is a message.
    Please help me with a problem.
    Thanks in advance.

    Hai ,
    You can send any message through response.sendRedirect();
    here is the coding try it
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class SimpleCounter extends HttpServlet {
    public void doGet(HttpServletRequest req, HttpServletResponse res)
    throws ServletException, IOException {
    res.setContentType("text/plain");
    PrintWriter out = res.getWriter();
    String username="java";
    res.sendRedirect("http://localhost:8080/yourprojectname/jspfile.jsp?username="+username);
    }

  • How to send the values from servlet to jsp

    hi folks,
    I need to send a lot of values from servlet to jsp so that i can display the values in jsp. Any sollution for this. Its very urgent.
    Thanks in advance

    Hi lieo,
    Can u send me the sample code for that.
    Thank q

  • How to return arraylist  from servlet to midlet

    hi everybody !
    Can anybody help me in solving this problem.
    I am working on an application in which I am using Midlet to servlet
    communication.
    In this I am sending username and password from Midlet to servlet .
    At server side servlet check the authentication and send the corresponding
    contactlist of user from database to the MIDLet.
    On Midlet this list should appear list-wise.
    please tell me that how can I achieve this....
    Thanks in Advanced....
    bhagwat

    Hi,
    Can u say how to lock folder without using any tools??
    If i click on folder,it should ask for password.if the entered value is valid,the folder should open....
    Can u provide code for this????
    Is there any need to interact with operating system???
    Please reply me soon..
    Thanks in advance...
    Vinoda

  • How to send mail from servlets

    m having troubles sending mail from servlets...
    how do you use the SimpleMailUser object needed in the session?
    a sample code on this would be of great help, thanks!

    <html>
    <body bgcolor="white">
    <font size=5 color="black">
    <%@ page import="javax.servlet.http.HttpUtils" %>
    <%@ page import="java.util.*" %>
    <%@ page import = "java.sql.*" %>
    <%@ page import = "java.io.*" %>
    <%@ page import= "sun.net.smtp.SmtpClient" %>
    <%
         String from,to,subject,msgbody,serverName;
         try
    from = request.getParameterValues("from")[0];
    to = request.getParameterValues("to")[0];
    subject = request.getParameterValues("subject")[0];
    msgbody = request.getParameterValues("msgbody")[0];
    serverName = request.getParameterValues("server")[0];
         catch (Exception e)          // Generally Speaking, an Error getting one of these
                                       // Values means that it wasnt passed in; inform the user
              out.println("You must call this JSP from this ");
              out.println("<A href=\"FormMail.htm\"> form</A>.<BR>");
              out.flush();return;
    %>
    Hold On A Moment while I try to Send Your Mail... <BR>
    <%
         out.flush();
         // Here are the real guts of the mail sending
         try
         sun.net.smtp.SmtpClient sm = new sun.net.smtp.SmtpClient(serverName);
         sm.from(from);
         sm.to(to);
         PrintStream msg = sm.startMessage();
         msg.println("To: ");     // Note dont use + for Performance
         msg.println(to);
         msg.println("Subject: ");
         msg.println(subject);
         msg.println();
         msg.println(msgbody);
         msg.println("==============");
         msg.print("This mail brought to you by JSP MAIL..from a user at IP ");
         msg.println(request.getRemoteHost());
         sm.closeServer();
         out.println("Your Mail Has Been Sent!");
         catch (Exception e)
              out.println("The mail couldn't be sent, probably because the mailhost wasnt set correctly.<BR> ");
              out.println("The error message I am getting is: ");
              out.println(e.getMessage());
    %>
    <BR>
    <BR>
    Click here to send another!

  • How to call any .tmpl file from servlet by sending some parameters ?

    Hi,
    I am new to Java Servlet and HTML template language ( anyfile.tmpl).
    I have created simple login authentication with user registration for new user.
    If user already exists, after successful login, he should be navigated to INBOX page (that inbox page is some inbox.tmpl file) from SERVLET itself using following BOLD statements given in code below. But its not working.. :-( Please do the needful.
    Thank you.
    if (session == null) {
         try {
              userName = request.getParameter("login");
              pwd = request.getParameter("password");
              if (!userName.equals("") && !pwd.equals("")) {
              try {
    //Database connection, data fetching, query execution etc.
    // code will go here
                   while (rs.next()) {
                   if (userName.equals(rs.getString("username")) & pwd.equals(rs.getString("pwd"))) {
                        String u_name = userName;
                        String ph_no = (new Integer(rs.getInt("ph_no"))).toString();
                        String address = rs.getString("address");
                        session = request.getSession();
                        session.setAttribute("user", userName);
                        String inbox = context.getInitParameter(INBOX);
                        Template inboxTmpl = new Template(inbox);
    *                    inboxTmpl.setParam("userName", u_name);*
    *                    inboxTmpl.setParam("ph_no", ph_no);*
    *                    inboxTmpl.setParam("address", address);*
    *                    out.println(inboxTmpl.output());*
                        System.out.println("Login successful..");
                        break;
                   rs.close();
         pstmt.close();
    con.close();
    (P.S - I am forced to use HTML.TEMPLATE(i.e. .tmpl file) instead of JSP)}

    Where does Template come from?
    But its not working.The other day I called the car repair shop. I told them my car did not work and I wanted them to fix it. They asked what was wrong, whether it did not start, whether suspicious sounds were heard, whether the car did not want to brake any longer, whether it gave a smoke from the exhaustion, whether the wind shield was broken, whether the oil was leaking etc. But I insisted just telling them "it doesn't work".

  • Sending a linked list from an applet to a servlet

    Does anyone know how I can go about creating a file in an applet and then writing it to my server? The applet collects lots of useful data and I want to store it on my server (Apache 1.3.26 running on Windows XP) for use at a later date. To complicate things further, the applet stores all the data as a linkedList of double[][]'s.
    I believe I may need to make a servlet to run serverside, but how do i send the linkedList to the servlet to create the file?
    Anyone know how I'd go about doing this?
    Cheers,
    Dan

    1 Use java.net.URL to connect to your server side servlet
    2 Obtain the OutputStream of the URL by calling URL.openConnection().getOutputStream()
    3 Wrap the OutputStram in step 2 with java.io.ObjectOutputStream
    4 Write the data array in the applet to the ObjectOutputStream
    5. In the servlet, read the data array using ObjectInputStream on the servlet request's input stream

  • Sending  unicode data to Excel from servlet displayed as "?"

    Hi,
    In my application we are export some unicode data to Microsoft Excel 2003 from servlet .
    For that i am using the following code.
    response.setHeader( "Content-Disposition", "attachment; filename=results.xls" );
    response.setContentType( "text/xls" );
    theHeader.append("\u30ec\u30dd\u30fc\u30c8 \u30bf\u30a4\u30c8\u30eb");
    The above unicode data (japanese character) not displaying properly in Excel (display as "?"). other non unicode things are display properly.
    can anyone advise me.

    I was having problems writing a unicode (utf-8 or utf-16) csv excel file, found a solution in the end ill post it here in case anyone else is looking.
    You need to use the funky encoding x-UTF-16LE-BOM
    an example of how to do this is
    Writer writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outputFile, true), "x-UTF-16LE-BOM"));
    then instead of using commas (,) use tabs (\t)
    then in my web.xml i have
    <mime-mapping>
    <extension>csv</extension>
    <mime-type>application/msexcel</mime-type>
    </mime-mapping>
    this site is a good reference
    http://members.chello.at/robert.graf/CSV/
    Hope this helps someone ! =]. I am using excel 2007may or may not work with earlier versions.

  • Exception during receive an array bytes from servlet

    Hi! I have some problem with receive my array bytes. When I want to recive my array bytes at application site from servlet, I have an exception java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source) near ObjectInputStream. I don't know what it's make. All looks good. Strings send I recive without any problems. Problem is with array bytes.
    URL url = new URL("http://127.0.0.1/App/servlet/Serwlet");
             URLConnection connect = url.openConnection();
            connect.setUseCaches(false);
             connect.setDefaultUseCaches(false);
             connect.setDoOutput(true);
         connect.setDoInput(true);    
    connect.setRequestProperty("Content-Type","application/x-java-serialized-object");
    ObjectOutputStream out = new sdfgObjectOutputStream(connect.getOutputStream());
              out.writeObject(arrayBytes);
              out.flush();
              out.close();
    //Here during debug is an exception
    ObjectInputStream in = new ObjectInputStream(connect.getInputStream());
              byte[] tmp = (byte[])in.readObject();
              in.close();
    System.out.println("Send array: "+arrayBytes);    
    System.out.println("Receive array: "+tmp);
    Servlet site :
    ObjectInputStream in = new ObjectInputStream(request.getInputStream());
                   byte[] tmp = (byte[])in.readObject();
                   in.close();
    response.setContentType("application/octet-stream");
                   ObjectOutputStream out = new ObjectOutputStream(response.getOutputStream());
                   out.writeObject(tmp);
                   out.flush();
                   out.close();Any ideas? :]

    All this exception looks that :
    java.io.EOFException
         at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
         at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Source)
         at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
         at java.io.ObjectInputStream.<init>(Unknown Source)
         at Klient.OdbiorcaButton.polaczenie(OdbiorcaButton.java:151)
         at Klient.OdbiorcaButton.actionPerformed(OdbiorcaButton.java:124)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Window.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

  • Problem in Passing JTree object from Servlet pgm to browser

    Dear all:
    Can anybody help to resolve the problem - pass the JTree obejct from servlet (Tomcat) to IE 6.0. The JTree oject alway shows invalid charcter in IE. Following is my coding.
    import java.io.*;
    import java.awt.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.swing.*;
    import java.net.URL;
    import java.sql.*;
    import java.lang.*;
    import java.util.*;
    import javax.swing.tree.*;
    //* Testing1 give it null
    public class SimpleServer extends HttpServlet
    DefaultMutableTreeNode top;
    DefaultMutableTreeNode EX01;
    DefaultMutableTreeNode EX02;
    DefaultMutableTreeNode QB01;
    DefaultMutableTreeNode QB02;
    DefaultMutableTreeNode N2BS;
    DefaultMutableTreeNode N2TS;
    //StringTokenizer st2, st1;
    String query;
    Connection con ;
    Statement statm;
    ResultSet res, backupRes;
    //RowSet res, backupRes;
    TreeSet treeset ;
    String [] tempArray;
    //ServletContext sc ;
    ObjectOutputStream out ;
    DefaultMutableTreeNode temp_node;
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
    resp.setContentType("text/html");
    // resp.setContentType("application/octet-stream");
    System.out.println("create main node") ;
              out = new ObjectOutputStream(resp.getOutputStream());
              out.writeObject(this.set_NodeMain()); //no DB access,
         public void doPost(HttpServletRequest req, HttpServletResponse resp)
         throws ServletException, IOException
         try
         System.out.println("doPost " );
         doGet(req,resp);
              finally
         public DefaultMutableTreeNode set_NodeMain()
    top = new DefaultMutableTreeNode("Tandem");
    EX01 = new DefaultMutableTreeNode("EX01");
    EX02 = new DefaultMutableTreeNode("EX02");
    QB01 = new DefaultMutableTreeNode("QB01");
    QB02 = new DefaultMutableTreeNode("QB02");
    N2BS = new DefaultMutableTreeNode("N2BS");
    N2TS = new DefaultMutableTreeNode("N2TS");
    top.add(EX01);
    top.add(EX02);
    top.add(QB01);
    top.add(QB02);
    top.add(N2BS);
    top.add(N2TS);
    return top;
    }

    JMO - I hate seeing things like this in code:
    Just use whitespace to separate the methods.
    You can't just send a JTree to a browser. A browser has no idea how to render a Java object.
    Put that JTree inside an applet and make it part of a JSP. That'll work.
    MOD

  • Error while sending a soap request from XML SPY to a webservice in XI

    Hi ,
    I published a webservice om the XI end and testing it with consuming the WSDL file in XML SPY and sending a soap request from there.
    I am getting the following error .
    <b>com.sap.aii.af.mp.module.ModuleException: either no channelID specified or no channel found for the specified party, service, and channel name</b>, MessageServlet(Version $Id: //tc/xi/645_VAL_REL/src/_adapters/_soap/java/com/sap/aii/af/mp/soap/web/MessageServlet.java#4 $)
         at com.sap.aii.af.mp.soap.web.MessageServlet.doPost(MessageServlet.java:380)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Is this error due to the user authentication or due to some other issue .
    Please do let me know soon .
    Thanks a lot
    Nikhil

    Hi Ricardo ,
    I have the correct port now.
    the url looks like
    http://<host>:50000/XISOAPAdapter/MessageServlet?channel=:SIEBEL_DEV:SOAP_CUST
    when I am testing it in the XML spy. and send a soap server request. I am getting the popup for user authentication . once i put my user id it gives me a error saying
    <b>HTTP operation 'POST' could not be performed on URL
    '/XISOAPAdapter/MessageServlet?channel=:SIEBEL_DEV:SOAP_CUST&amp;version=3.0&amp;Sender.Service=SIEBEL_DEV&amp;Interface=http%3A%2F%2FOFCOM%2FUNIFY%2FCustomerMaster%5EMI_CUST'  due to an error :
    The connection to the server was terminated abnormally</b>
    Any Idea as to why is such a error is coming
    Thanks for the help
    Nikhil

  • Getting the values from   Servlet

    Hi EveryOne,
    I have done one thing using Flex,i have send the parmeters
    from flex to servlet using HttpService and in the servlet i
    captured them and used them.Now what i want is i have to capture
    the values from servlet to flex .
    Response content in servlet is set to text/xml,any one please
    give me the idea how to do thsi or please send me some code to do
    this.
    {Sorry for my English} Thanks,
    Namala.

    Hi,
    You have to handle the result event of the HTTPService
    component. In the result handler you will have access to the
    ResultEvent object which will contain the response from the server
    in the "result" property. Please visit the URL below for more
    details on how to handle result from the server.
    http://livedocs.adobe.com/flex/3/html/data_access_6.html#235586
    Hope this helps.

Maybe you are looking for