How to pass a string from a servlet to client side

hi,
i would like to generate a string from a servlet and pass it to the client side. the client will receive the string by using request.getParameter(). How should i implement this system? Could anybody give me some hint?
Best Regards,
Henry

Greetings,
hi,
i would like to generate a string from a servlet and
pass it to the client side. the client will receive
the string by using request.getParameter(). HowAre you referring to the instance of (Http)ServletRequest the 'request' object being passed to the "client"? What is the "client" in this case? If you mean a "traditional" client communicating over (or by tunneling through...) HTTP then no can do. The (Http)ServletRequest object is generated by the web container (a.k.a. "servlet engine"), not by the client, and it is not serializable so there is no way to pass it back to the client...
should i implement this system? Could anybody give me
some hint?It depends again on "what is the 'client' in this case?"
Best Regards,
HenryRegards,
Tony "Vee Schade" Cook

Similar Messages

  • How to pass submitted Data from a servlet to EJB Session Bean in JPA

    How to pass Data User submitted Data from a servlet to EJB Session Bean when using JPA :
    Hi ,
    I have a jsp page in which the user fills up the Data and submits it to the servlet :
    Inside servlets i am getting all the parameters and setting it to the Entity Class .
    Sample Entity class is shown below :
    @Entity
    public class Employee {
    @Id private int id;
    private String name;
    public Employee() {}
    public Employee(int id) { this.id = id; }
    public int getId() { return id; }
    public void setId(int id) { this.id = id; }
    public String getName() { return name; }
    public void setName(String name) { this.name = name; }
    }After calling setters of my Entity Class .
    I am using JNDI lookup to call my session Bean method and pass this Entity class to the session Bean to persist data
    Please let me know what will be the right approach :
    1. Passing parameters whole as a Entity Class
    that is
    public void insertData(Employee emp)
    }Or
    2. public void insertData(String Name , int ID)
    }

    they are both right as they both work. Easy huh?
    You might argue that if you have to set a lot of fields, use the entity as otherwise you get a method with a gigantic amount of parameters.

  • How to pass a string from a child thread to a parent thread ?

    I have a Server class listening to a particular port continuously using TCP Sockets . Whenever a client connects to this server socket, a new thread is created to obtain the data from the client socket. The following code shows how this is done -
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.*;
    public class TransportHandler extends Thread{
              ServerSocket server_socket;
              int myListeningPort;
              public String clientReq = "";
              public TransportHandler() throws IOException{
                   super();
                   myListeningPort = 80;
                   CreateServSocket();
              //throw the socket exception outside, so that it can be handled
              public TransportHandler(int port) throws IOException{
                   super();
                   myListeningPort = port;          
                   CreateServSocket();
              private void CreateServSocket() throws IOException{
                            //create serversocket
                   server_socket = new ServerSocket(myListeningPort);
              public void printmsg(){
                   System.out.println(clientReq);
              @Override
              public void run() {
                   // TODO Auto-generated method stub
                   StartListening();
              public void StartListening(){
                   while(true){
                        //loop forever listening to connections
                        try {
                             Socket clientSocket = server_socket.accept();
                                             //create new thread to handle client connection
                             Thread clientthread = new Thread(new ClientConnectionHandler(clientSocket));
                             clientthread.setName("Client Handler");
                             clientthread.start();
                             printmsg();
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
              public void StoreReq(String msg){
                   clientReq.concat(msg);
              private class ClientConnectionHandler implements Runnable{
                   Socket ClientSock;
                   BufferedReader sockReader;
                   InputStreamReader isReader;
                   String messageFromClient;
                   public ClientConnectionHandler(Socket sock){
                        ClientSock = sock;
                        try {
                             isReader = new InputStreamReader(ClientSock.getInputStream());
                             sockReader = new BufferedReader(isReader);
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
                   @Override
                   public void run() {
                        // TODO Auto-generated method stub
                        int c= 0;
                        try {
                             while( (messageFromClient = sockReader.readLine())!= null){
                                  StoreReq(messageFromClient);  
                             //System.out.println("clientreq = "+clientReq);
                        } catch (IOException e) {
                             // TODO Auto-generated catch block
                             e.printStackTrace();
    }The TransportHandler is instantiated from another class HttpMessageHandler as shown below -
    import java.io.IOException;
    public class HttpMessageHandler {
         public static void main(String[] args){
              try {
                   TransportHandler server = new TransportHandler();
                   server.start();
              } catch (IOException e) {
                   // TODO Auto-generated catch block
                   e.printStackTrace();
    }So in the above code when the server.start() is executed, the run() method in TransportHandler is executed. How do I get the string contained in clientReq in HttpMessageHandler after the data from client socket is fully read ?
    Edited by: turing09 on Dec 12, 2009 2:13 PM

    Okay, to make my problem more clear to you - basically I am trying to create a simple Http Server, wherein the HttpMessageHandler is an interface between the Http layer & the Transport layer (represented by TransportHandler class). I am trying to code it bottom-up. In my design I require the TransportHandler class to get the client http request data from the TCP socket and pass it onto the HttpMessageHandler class.
    At the same time TransportHandler class must continuously listen to the port to receive other connections. For every client connection, the TransportHandler creates a new ClientHandler thread & this new thread gets the data. The TransportHandler instance & the ClientHandler instance are running in seperate threads. The HttpMessageHandler is running in the main thread. Please note: the member variable clientReq is private & not public
    The problem I am facing here is that even when the ClientHandler thread finishes, I am not able to print the client request data in HttpMessageHandler thread.
    I am able to print the String in the run() method of ClientHandler but not in HttpMessageHandler main() method.
    Any solutions for this?
    Edited by: turing09 on Dec 12, 2009 5:24 PM
    Edited by: turing09 on Dec 12, 2009 5:25 PM

  • How to pass query string from content editor webpart to another?

    Hi All,
    I am using content editor web-part to show GooglePiechart  for workflow status column in a list. When user click on chart, i need to show particular clicked area data in another list web-part. So that, i need to pass the query value from content editor
    web-part to another web-part. How to achieve this scenario?

    Hi Sam,
    What you can do is using SPD create a data view webpart which excepts query string value as filters as shown in the below article
    http://madanbhintade.wordpress.com/2012/01/08/sharepoint2010dataviewwebpart/
    http://sharepoint.stackexchange.com/questions/55184/how-to-filter-dataview-webpart-dvwp-from-query-string
    Then When you click on the pie charts particualr section perform a post back  by appending the required query string paramter to the same page on which your webpart exist
    Raghavendra Shanbhag | Blog: www.SharePointColumn.com
    Please click "Propose As Answer " if a post solves your problem or "Vote As Helpful" if a post has been useful to you.
    Disclaimer: This posting is provided "AS IS" with no warranties.

  • How to pass a JavaBean from servlet to JSP?

    Hi there,
    I am working on a project that needs to handle quite a few client requests and I want to use the Front Controller pattern that is described in the J2EE pattern page.
    The steps described in the front controller pattern is that:
    1. A servlet (controller) process the client request.
    2. It calls the appropriate cammand object and the cammand object gets the data from the data source and returns a JavaBean that contains the required data.
    3. The servlet dispatch to the appropriate View (jsp page)
    4. The JSP page displays the data in the JavaBean to the user.
    However, I don't know how to pass the JavaBean from the servlet to the JSP page when the servlet forwards the control to the JSP page. Should I make the JavaBean with a request scope or higher? If so, how to uses it in the JSP page? Just refer by the ID of the JavaBean.
    If any one knows there is an example or tutorial on how to use this pattern, please let me know.
    Thank you !
    Regards
    Edmund

    Could you please give more info? i tried to do this, but always get a "Class not found exception":
    response$jsp.java:65: Class org.apache.jsp.TestBean not found. TestBean bean = null;
    although the class TestBean (no package name => defalt package) is in the WAR file and the Servlet seems to instantiate it (otherwise an exception would occur sooner in the TestServlet code).
    my JSP code is:
    <%@ page language="java" info="Response page" %>
    <jsp:useBean id="bean" class="TestBean" />
    <%
    TestBean bean2 = (TestBean) request.getAttribute("TheBean");
    %>
    <html>
    <body>
    Your value: <%= bean2.getValue() %><BR>
    My val: <%= bean2.getNewValue() %><BR>
    <P>
    Date: <%= new Date() %>
    <P>
    Neuen Wert eingeben
    </body>
    </html>
    --------------

  • Passing a String from Java to Javascript

    Does anybody know how to pass a string from Java class to Javascript ? Can it be done?

    If you are talking in terms of web terminology...
    People do intialization of page in the following way.
    var java_script_variable = <%=String_variable%>

  • How to pass a string value from XL sheet cell to SQL query.

    Hi,
    I am using SQL query in XL sheet to fetch some data. for that i am using ODBC connection. Now I want to pass a string from XL sheet Cell value in the where clause of Select statement, Please let me know how to do this.
    Below is My code:
    nge("A4").Select
    With ActiveSheet.QueryTables.Add(Connection:= _
    "ODBC;DRIVER={Microsoft ODBC for Oracle};UID=xyz;PWD=xyz;SERVER=xyz;" _
    , Destination:=Range("A4"))
    .CommandText = Array( _
    "SELECT CRYSTAL_REPORT1.PROJECT, CRYSTAL_REPORT1.OBJECT" & Chr(13) & "" & Chr(10) & "FROM NAIODEV.CRYSTAL_REPORT1 CRYSTAL_REPORT1" _
    .Name = "Query from gg"
    Thanks,
    Priya

    What does "XL" (whatever that is) have to do with Crystal Reports which is what you are obviously working with have to do with the Oracle database?
    The rules for using Crystal with Oracle are quite clearly described in all the Crystal Reports docs ... you MUST use IN OUT ref cursors unless you are doing direct table or view access.

  • How do I Display a string from a servlet into a JSP Page???? NEED HELP!!!!

    Hi guys,
    How do I Display a string from a servlet into a JSP Page...
    Ive tried so many bloody things!.....
    Simply.
    I get text from JSP. The servlet does what ever it does to the string.
    Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
    please help!!!

    hmmm, I dont really like using JSP programming, u should be using JAVA..
    the way to do it is:
    Call and cast to the bean like this:
    <%@ page import="beans.*" %>
    <% //cast to bean get request create object
    userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
    then... all you do is call it like this:
    <input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
    this is the real programmers way,,,
    chet.~

  • Re: Passing a string from Java class to JSP

    How can I pass a string from a function within my bean class to my JSP page?
    I would like to pass something like this with the necessary params filled in:
    String myString ="Successful <b>" + Sales.getActionType() + "</b> was made on <b>" + (new Date()).toString();
    The ActionType will be either a BUY or SELL and the current date need to be added in.
    Thank you in advance!

    SOLVED THE PROBLEM!!!

  • How to pass an object from jsp to other jsp using SendRedirect

    How to pass an object from one jsp to the other jsp using ssendRedirect with out using the session
    I am having 2 jsps
    x.jsp and y.jsp
    From x.jsp using sendRedirect iam going to y.jsp
    From x.jsp i have pass an object to the y.jsp
    Is it possible without putting the object in session
    Is it possible using EncodeUrl
    Please help me Its Urgent

    Is it possible without putting the object in sessionAnything is possible. Would you accept that it is very difficult?
    When you send a redirect, it tells the browser to send a new request for the target page. That means any request parameters/attributes are lost.
    Is it possible using EncodeUrl response.encodeURL() puts the session id into a url if the browser does not support cookies. It is purely for retaining the session.
    There are two ways that you can communicate across a sendRedirect.
    1 - use the session
    2 - pass a parameter in the url.
    parameters are string based, so passing objects is almost out of the question.
    Potentially you could serialize your object, encode it in base64 (so it is composed completely as characters) and pass it as a parameter to the other page, where you retrieve it, unencode it, and then load the serialized object.
    Or you can just use the session.

  • How to pass the data from a input table to RFC data service?

    Hi,
    I am doing a prototype with VC, I'm wondering how VC pass the data from a table view to a backend data service? For example, I have one RFC in the backend system with a tabel type importing parameter, now I want to pass all the data from an input table view to the RFC, I guess it's possible but I don't know how to do it.
    I try to create some events between the input table and data service, but seems there is no a system event can export the whole table to the backend data service.
    Thanks for your answer.

    Thanks for your answer, I tried the solution 2, I create "Submit" button, and ser the mapping scope to  be "All data rows", it only works when I select at least one row, otherwise the data would not be passed.
    Another question is I have serveral imported table parameter, for each table I have one "submit" event, I want these tables to be submitted at the same time, but if I click the submit button in one table toolbar, I can only submit the table data which has a submit button clicked, for other tables, the data is not passed, how can I achieve it?
    Thanks.

  • How to pass multiple values from workbook to planning function ?

    Hi,
    I have created Planning function in Modeler and it has one parameter(Variable represents = Multiple single values).
    When executing the planning function by create planning seq. in the web template : I see value of variable store data like ...
        A.) input one value -> V1
        B.) input three values -> V1;V2;V3
    This function execute completely in web.
    However, I want to use the planning function in workbook(Excel).
    The value of variable can't input V1;V2;V3... I don't know how to pass multiple values from workbook to parameter(Multiple single values type) in planning function ?
    thank you.

    Hi,
    Please see the attached how to document (page no 16).
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f0881371-78a1-2910-f0b8-af3e184929be">how to</a>
    Hope this was helpful
    thanks

  • Is it possible to pass a string from an applet to the web site?

    Hi, everybody!
    Is it possible to pass a String from an applet to a web site (as a field value in a form, an ASP variable, or anything else). Basically, I have a pretty large String that is being edited by an applet. When a user clicks on the submit button, a different page will show up which has to display the modified string. The String is pretty large so it doesn't fit into the URL variable.
    Please, help!
    Thank you so much!

    Why do you want to do this in Java?
    Javascript is the correct language for these type of situations.
    for instance:
    in the head of your html document:
    <script language=javascript type="text/javascript">
    createWindow(form){
    if(form.text.value!=""){
    newDoc = new document
    newDoc.write(form.text.value)
    newWin = window.open(document,'newWin','width=200;height=150')
    </script>
    in the body:
    <form onSubmit="createWindow(this)">
    <p>
    Enter a String:<input type=text size=30 name="text">
    </p><p>
    <input type=submit value="submit"> 
    <input type=reset value="reset">
    </p>
    </form>

  • Regarding how to pass the data from web dynpro to workflow

    hi gurus,
    how to pass the data from web dynpro to workflow.
    Regards
    vijay

    Check this [thread|SAP_WAPI_START_WORKFLOW;

  • How to pass the data from web dynpro to workflow.

    hi gurus,
    how to pass the data from web dynpro to workflow.
    Regards
    vijay

    Hi
    you can use function module
    data   ls_input_container  TYPE swr_cont.
    data   lt_input_container  TYPE TABLE OF  swr_cont.
    CALL FUNCTION 'SAP_WAPI_START_WORKFLOW'
        EXPORTING
          task            = ptask
        IMPORTING
          return_code     = lv_return_code
          new_status      = lv_new_status
        TABLES
          input_container = pinput_container
          message_lines   = lt_message_lines
          message_struct  = lt_message_struct.
    where you pass the data in imnternal table "pinput_container" as
      ls_input_container-element = 'KUNNR'.
      ls_input_container-value = ls_skna1-kunnr ."wd_this->lv_kunnr.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'CLUSER'.
      ls_input_container-value = lv_cluser.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'BUKRS'.
      ls_input_container-value = lv_bukrs. " youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'VKORG'.
      ls_input_container-value = ls_sknvv-vkorg. " youe value as per requirement
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'VTWEG'.
      ls_input_container-value = ls_sknvv-vtweg. "youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
      ls_input_container-element = 'SPART'.
      ls_input_container-value = ls_sknvv-spart. "youe value as per requirement.
      APPEND ls_input_container TO lt_input_container .
    *Also Forgot to mention where ptask is your workflow ID *
    Regards,
    Arvind
    Edited by: Arvind Patel on May 14, 2010 7:38 AM

Maybe you are looking for