DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Oct 2006
    Posts
    1

    Passing attributes from applet to jsp

    Hi,

    I am developing a web application where i use applet to fetch i/p from keyboard through applet and passs this as an attribute to jsp.

    i dont knoe how to do that.Could you please help me?

    Thanks

  2. #2
    Join Date
    Oct 2006
    Posts
    5

    Applet and Servlet Communication

    In the Applet and Servlet ( JSP ) communication, applet act as a client just like a browser and the Servlet or JSP act as a server.
    Now, the applet can send GET or POST requests to the servlet or JSP and in turn receive data from them.
    You just have to create a URLConnection from the URL of the servlet and write or read from the Output/InputStream.

    For eg.

    in your applet, create a URLConnection object like this: -

    URL url = new URL(getCodeBase(), "<servlet>" )
    URLConnection connection = url.openConnection();

    now, read or write to the servlet: -

    connection.setDoInput(true);
    InputStream istream = connection.getInputStream();

    or

    connection.setDoOutput(true);
    OutputStrem ostream = connection.getOutputStrem();

    In case of reading and writing Objects, you can open a ObjectInputStream or ObjectOutputStream. But remember to set the Content-Type of the Output stream while writing to the servlet to the appropriate type.

    I think this much information will get you started!

Similar Threads

  1. Java Applet embedded in a JSP Page
    By JLRodz in forum Java
    Replies: 4
    Last Post: 11-23-2005, 09:49 AM
  2. Replies: 0
    Last Post: 11-14-2001, 07:02 AM
  3. Replies: 3
    Last Post: 08-23-2001, 11:01 AM
  4. Opening Applet from JSP
    By Dave Freyer in forum Java
    Replies: 0
    Last Post: 10-31-2000, 05:14 AM
  5. Replies: 2
    Last Post: 05-07-2000, 01:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links