How do i send data to a servlet through a hyperlink?

i have /Servlet?id=1
is that the way to do it...? please help.. i want the id to be sent to the servlet...
the url mapping works fine but i keep getting null values......when reaching the final page...
thanks

the value is the value of a picture being displayed in the user home page..when displaying the pictures..a sql query is executed and the result appended to the hyperlink each time a resultset is returned..
actually i have managed to get it to workk.....
thanks guys

Similar Messages

  • How does a JSP page send data to a servlet?

    I know, elementary school question, but I can't seem to do it no matter what I tried to do. Here is my code:
           URL url = new URL("http://" + ChatGlobals.SERVER_NAME + "/" +
                    ChatGlobals.SERVLET_PATH + "/ppowell.ChatServlet?message=" +
                    URLEncoder.encode("/a " + cookieArray.getValue())
    out.println("<P>" + url.toString());
    HttpURLConnection conn = (HttpURLConnection)url.openConnection();
    conn.setDoInput(true);     // NOT REALLY INTERESTED IN INPUT BUT MUST BE TRUE
    conn.setDoOutput(false);     // NO OUTPUT
    conn.setUseCaches(false);
    conn.setDefaultUseCaches(false);
    conn.setRequestProperty("Content-type", "text/plain");
         * Do servlet connection to retrieve from ChatServlet URL instance
         * by instantiating an InputStreamReader object
         * @see ChatServlet
    BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
    String stuff = null;
    stuff = in.readLine();
    out.print(stuff);
    in.close();
    in = null;
    conn = null;
    Upon running this code my page just locks up.. URL: http://www.myjavaserver.com/~ppowell/chat.jsp
    But if I call the servlet directly:
    http://www.myjavaserver.com/servlet/ppowell.ChatServlet?message=/a+Phil
    Everything works perfectly, no lockups, no errors, the log and txt files are created. So if my browser calls the servlet everything is ok, but my JSP script in the same directory as my servlet is the one that needs to call the servlet.
    How then does a JSP send data to a servlet?
    Please help, I've been searching in books and online resources for days now with absolutely no apparent luck to do it.
    Thanx
    Phil

    It's correct that a JSP is compiled to a servlet. All HTTP servlets receive requests and send responses via HTTP, of course.
    But this JSP is making a URL connection to a servlet and sending data.
    Are you sure that the URL your JSP creates is identical to the one that works in your browser? Have you printed it out to stdout to verify that it's true? (Code inspection and "it looks right" doesn't count.)
    Why are you doing it this way? It's common to have a JSP send to a servlet, but the usual way of doing it is to put an HTML form in the JSP, including an HTML <input type="submit">, and POSTing the form data to a servlet URL. Why aren't you doing that? - MOD

  • Can a HTML form send data to two servlets?

    I would like to know if an HTML Form can send data to two servlets, I guess I am askin is that can the parameters be passed to two ACTION attributes??

    Hmmmm, well I'm not sure if that is possible, but you could do something of the sort on the server side by chaining them.... the technieque is called Servlet Chaining
    Hope this helps
    Omer

  • How do I send E-Mail using Servlet or JSP?

    Hi friends,
    Anybody can you please tell me how do I send an email in Servlet or JSP?
    Do I need any special configuration to check in my server space?
    I am puzzled because after surfing on net, I found that some people sending email with Javamail and Activation API
    and some people sending email using import="sun.net.smtp.SmtpClient";Please give me some simple direction or any working code if possible.
    Thanking u,
    ---Sujoy

    What you need is a working SMTP account to be able to send email, that is accessible from the server. If you have that, simply use JavaMail.

  • Send data to ECC table through RFC Call function from SAP B1 via  b1if

    Hi,
    I have created scenario in B1if which triggers from SAP B1, now I have to send this data in to ECC table, so I have created scenario for that with inbound SAP B1, outbound void and in process RFC Call atom is there but I am not getting data in receiver and also how to write xml to send data in RFC function. Function for RFC has configured from ECC end and have access of that function.
    So please help me to send data to ECC table through RFC Call function from SAP B1 (9.0) via b1if
    Thanks

    Solved by my own.

  • How to avoid invalid data entering in LOV through code

    hi
    1)i have developed lov in table region, but user easily can enter invalid data and saved into the database tables.
    2)i created one formvalue and mapping into that return item , still its not working in table region LOV.
    3)how to avoid invalid data entering in LOV through code. i have tried this below code in EOimpl set value method. but some how its not wokring.
    if (value!=null)
    throw new OAAttrValException(OAAttrValException.TYP_ENTITY_OBJECT,
    getEntityDef().getFullName(),
    getPrimaryKey(),
    "ProcurementCategory",
    getProcurementCategory(),
    "FND",
    "FND_LOV_SELECT_VALUE");
    Thanks.
    krish.

    Thanks reetesh and gourav for your help.
    i followed below mapping details
    LOV Item Properties
    ID -PurcCommodity
    ViewInstance -VendorVO1
    ViewObject -PurcCommodity
    map1 properties
    LOV Region Item - segment1
    Return Item -PurcCommodity
    CriteriaItem -PurcCommodity
    Usefor Validation -Default
    map2 properties
    LOV Region Item - segment1
    Return Item -validation(formvalue)
    CriteriaItem -
    Usefor Validation -yes
    form value properties
    ID -validation
    ViewInstance -VendorVO1
    ViewObject -PurcCommodity
    Gourav- i double checked multiple rows it is not working, some times it is not working for single row too.
    Thanks
    krish.

  • Error while executing servlet through a HyperLink.

    Hi
    When i am trying to execute a servlet through the HyperLink using this statement
    where CallStatusDetailsAssign is my servlet.then i am getting this error :
    The Following is the Alert Message.
    1. Microsoft InterNet Explorer
    http://localhost:8080/examples/servlets/CallStatusDetails?Call_ID=1&EMP_NO=1
    ** Download of the specified Resource has failed.
    & also getting this error:
    2. IE Cannot open the Internet Site
         ** Operation has been Cancelled.
    If i refresh the screen by clicking on refresh button in the Internet Explorer.the Page is getting displayed properly.
    Is there any problem with my servlet code ??or some other Problem.
    Can Anyone Please help me on this & give me the Solution for my Problem.
    Rashmi

    I'm not sure if this is cause of your problem but the anchor tag should look like this:
    some text</ a>
    ... in the code the quotes are missing
    spieler

  • How Can I Send Data From One Pc To Another Using An Ethernet Connection ?

    Hi,
    I would Like to know how to send data ( For example, any String ) from a Server Pc to a Client Pc, Using the same java program installed on both computers.
    [Pc One ( Server ) [ Java Program] ] <----Ethernet--Cable----> [Pc Two( Client ) [ Java Program] ]
    Thanks .
    Edited by: jaysal2490 on Jul 7, 2008 9:45 PM
    Edited by: jaysal2490 on Jul 7, 2008 9:46 PM
    Edited by: jaysal2490 on Jul 7, 2008 9:51 PM

    Check out this tutorial:
    http://java.sun.com/docs/books/tutorial/networking/sockets/index.html
    There are code samples included.

  • How can i send data POST with a html link in a textfield

    Hello,
    This is my problem : I generate (from a php script) html
    links in a textfield. I would like for each link to send data with
    the POST method to an other script.
    My problem is that the getURL("lien", "", "POST") function
    can be use only by a movieclip or button event ... and not from a
    html link ...
    How can i do it ?
    Have you a small idea???
    Thanks ....

    yes, thanks but now my problem is in my function associated
    to this link :
    function SendPost()
    var toto="toto";
    getURL("
    http://127.0.0.1/board/scheduledfirst.php",
    "_blank", "GET");
    The function is executed but after in php i can get anything
    with echo ($_GET["toto"]); echo ($_POST["toto"]);
    Why ?

  • [iPhone] How would one send data to an http server?

    Hello,
    I would like to be able to send data (maybe XML?) to be processed by a server-side script.
    NSURLRequest seems to be mainly for downloading data, not uploading... A simple "ajax" request would do, so I would just serialize the data and send it in a POST variable. How do I implement such a request using the SDK?

    This what iam doing to post XML and to receive an XML response from our servers. Note that the Content-Type is set to text/xml. If your post data is different, set the type accordingly.
    Also i am using *NSURLConnection -> sendSynchronousRequest* class method to block for the response. You can also do asynchronous read of the response by creating a NSURLConnection object and setting a delegate which will listen for the incomming network events. Check the documentation for NSURLConnection .
    Hope this helps,
    -TRS
    // This method takes an XML post data and returns the response XML from server
    // Note that if you want to post binary data then just send postData instead of
    // postString as input parameter
    - (NSString *) postData: (NSString *) postString toURL:(NSString *) url {
    NSData *postData = [postString dataUsingEncoding: NSUTF8StringEncoding];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:url]
    cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:10];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"text/xml" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];
    NSURLResponse *response = nil;
    NSError *error = NULL;
    NSData *respData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
    NSString *responseString = nil;
    if (!error && respData) {
    if ([response isKindOfClass:[NSHTTPURLResponse class]]) {
    int code = [((NSHTTPURLResponse *)response) statusCode];
    if (code == 200) {
    responseString = [[[NSString alloc] initWithData:respData encoding:NSUTF8StringEncoding] autorelease];
    } else {
    NSLog(@"
    Error");
    } else {
    NSLog(@"
    Error");
    [request release];
    return responseString;

  • 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 can i send parameter to the servlet

    i want send one or more parameter to the servlet
    acturally i am using applet servlet cmmunication
    useing XML and I want to send one parameter to
    the server and depending on tha perform some
    action but i dont know how to send the parmer to
    servlet plz give the answere
    Rahul

    Hi Rahul,
    You will have to use java.net package for tht.. Through applet you will have to make URL connection to your servlet.whc u will make by using java.net.URl
    Just explore this pakage. You will find alots of utility thr.
    HTH?
    ~Gaurav

  • How can I send data from a Comp to a Service?

    Hello!
    I have written a simple service, it works fine, i can receive data from it, but i need also to send data to the service.
    I have tried this:
    part of the code of my service:
    public void addUser(String UserName) {
                   UserList[number_user] = UserName;
                   number_user++; 
    part of the code of my comp:
    IszerdService myService = (IszerdService) PortalRuntime.getRuntimeResources().getService(serviceName);
    myService.addUser("Superman");
    could you show me what is the most simple way to send data to a service, and store in the service?
    thank you all!
    Istvan

    Hi Subathra,
    > Where do u face problem? Did u get any error while
    > le passing the data to the service? What's that?
    Actually I cant deal with putting data into the String Array of my service.
    Now I have solved the problem by using HashTable instead of String[] and the .put(key, object) method works fine, the data is delivered to the service succesfully.
    Regards,
    Istvan

  • Sending data to a Servlet. EOFException and StreamCorruptedException.

    Hi!
    I have a small servlet that receives some text from a client, and returns a response. The problem is that when i try to receive the data in the servlet, I get and EOFException. And when the client tries to read the response, a StreamCorruptedException is thrown. Can anybody please point me in the right direction here?
    The code for servlet is as follows:
         protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
              DataInputStream in = new DataInputStream((InputStream) request.getInputStream());
              String message;
              String text = null;
              try {
                   text = in.readUTF();//EOFException thrown here!
                   message = "100 ok";
              } catch (Throwable t) {
                   message = "200 " + t.toString();
              response.setContentType("text/html;charset=UTF-8");
              response.setContentLength(message.length());
              in.close();
              PrintWriter out = response.getWriter();
              out.println(message);
              out.flush();
              out.close();
              System.out.println(". Received text: " + text == null ? "none" : text);
         }And the code for the client:
         @Test
         public void test2() throws IOException, ClassNotFoundException {
              String input = "This text is to be sent";
              URL serverURL = new URL("http://localhost:8080/myURL");
              URLConnection con = serverURL.openConnection();
              con.setDoInput(true);
              con.setDoOutput(true);
              con.setUseCaches(false);          
              con.setRequestProperty("Content-Type", "application/x-java-serialized-object");
              OutputStream outstream = con.getOutputStream();
              ObjectOutputStream oos = new ObjectOutputStream(outstream);
              oos.writeObject(input);
              oos.flush();
              oos.close();
              InputStream instr = con.getInputStream();
              ObjectInputStream inputFromServlet = new ObjectInputStream(instr);//StreamCorruptedException thrown here ("invalid stream header")
              String result = (String) inputFromServlet.readObject();
              inputFromServlet.close();
              instr.close();
              System.out.println(result);
         }The EOFException is thrown at the line text = in.readUTF(); in the servlet, and the StreamCorruptedException is thrown at ObjectInputStream inputFromServlet = new ObjectInputStream(instr); in the client. What is wrong here?
    Edited by: Fush on Apr 15, 2008 6:59 AM
    Edited by: Fush on Apr 15, 2008 7:00 AM
    Edited by: Fush on Apr 15, 2008 7:03 AM

    Your server reads a UTF-encoded String with readUTF().
    So your client should write a UTF-encoded String with writeUTF().
    Your server writes lines with PrintWriter.println().
    So your client should read lines with BufferedReader.readLine().

  • How can I send request to the server through XML using JSP

    How can I send XML request to the server using JSP and servlets

    Ajax may be the one way.

Maybe you are looking for

  • Facing problem in Fetching Employee details

    Hello All, i need to write a abap coding to fetch the employee details from the corresponding table,i worte a code but its is not fetching the details of the employess in to the output,am sending my code along with this thread its great if any body h

  • Illustrator CS4 crashes when Photoshop is open

    Hi, I have a problem with Illustrator CS4. Whenever I have Photoshop CS4 open at the same time as it, the program crashes completely, giving no error message to indicate why. It runs totally fine as long as Photoshop isn't already open, or as long as

  • Issues resolved by Adobe Reader 8.1.2

    According to the release notes for Adobe Reader 8.1.2, resolved issues include: "1574838 Improved printing on HP-based printers" "1607532 Added PCL print improvements" How can I get more details about these issues and the fixes?

  • New line installation question

    I live in a house that has never had a line connected, so I am having a new line fitted. I am having phone and infinity 38Mb. Will the installation engineer just fit one master socket to be used for the phone and modem, or will they fit a seperate po

  • Check deposit with smartform

    Hi experts! I have to replace a sapscript by a smartform for transaction FF68 and I don't know how I can do it. If I'm not wrong there are no user exit or enhancement planned to do that. I try to do it with Business Transaction Event but I don't know