[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

JSP+Applet

Posted on 2001-07-17
10
Medium Priority
?
496 Views
Last Modified: 2013-11-24
is it possible to transfer information from an applet (fx a string) to a JSP-page???? the transfer should start when i push a button on the applet.

if possible give a small and simple example.
0
Comment
Question by:pattefar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
  • +3
10 Comments
 
LVL 92

Expert Comment

by:objects
ID: 6291825
Once the jsp page has got to the browser it is just plain old html, so there's not a lot of interacting you can do with it. You may be able to something with javascript.
What is it you want to do?
0
 

Author Comment

by:pattefar
ID: 6293182
so this means that an applet can't send information to a JSP-page, but a html-page can, if you use a the form-tag??

how do i send information from javascript to the jsp-page, fx when i push a javascript-button?????is this even possible????
0
 
LVL 92

Expert Comment

by:objects
ID: 6293265
What is it exactly you want to do, we may have some terminology confusion.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:ibo
ID: 6293667
applet and servlet can talk to each other.
and since JSP is just an abstraction of servlet..
probably its possible :).
0
 
LVL 1

Expert Comment

by:ny971181
ID: 6294864
yes, it is possible!

allow me some time to create some samples for you, it will be available tonight. :)

if you can't wait, I can explain a little bit for you.

in an HTML Page with Javascript, you can something like this:

...
<script Language="Javascript">
...
function setaction
{
 form1.action="xxx.jsp"
}
...
</script>
...
<form name='form1', method='post' action=''>
...
<input type=button name='b1' onclick='setaction()'>
...
</form>

so when you click the button 'b1', setaction() function is called and form1's action property is set to xxx.jsp.
and when the form1 is submitted(post), the xxx.jsp page is called and executed.

good luck
0
 

Author Comment

by:pattefar
ID: 6295254
thx for the answers!!! could anybody give an example where i enter a string in a textfield in an applet and when i push a button on the applet, then the string is transferred to the jsp-page. the example don't have to include any javascript.
0
 
LVL 92

Expert Comment

by:objects
ID: 6296470
If you just want to load a jsp from your applet, then it's exactly the same as loading a html page from your applet.
0
 
LVL 3

Expert Comment

by:ibo
ID: 6296756
from ur applet..

                   //  posting multiple Serialized objects to a Java servlet and getting objects  in return
     static public ObjectInputStream postObjects(URL servlet, Serializable objs[]) throws Exception
     {
          URLConnection con = servlet.openConnection();
          con.setDoInput(true);
          con.setDoOutput(true);
          con.setUseCaches(false);
          con.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");

          // Write the arguments as post data
          ObjectOutputStream out = new ObjectOutputStream(con.getOutputStream());
          int numObjects = objs.length;
          for (int x = 0; x < numObjects; x++) {
               out.writeObject(objs[x]);
          }

          out.flush();
          out.close();

          return new ObjectInputStream( con.getInputStream() );
     }

from ur servlet...

     public void doPost(HttpServletRequest req, HttpServletResponse resp)
     throws ServletException, IOException
     {
          // Open the I/O streams
          ObjectInputStream in = new ObjectInputStream(req.getInputStream() );
          ObjectOutputStream out = new ObjectOutputStream( resp.getOutputStream() );
          try {
               // 1. Read in parameters from the applet
               String id = (String)in.readObject();
               UserData data = (UserData)in.readObject();

               // 2. Execute the RMI call
               db.editUser(id, data);

               // 3. Write the result
               // [no return value]

          } catch (Exception e) { e.printStackTrace(); }

          // Close the I/O streams
          in.close();
          out.close();
     }

this is not my code.. just copy pasted it.

look for the article in javasoft.com for :
Java Servlets and Serialization with RMI
OR get the book by jason hunter 'Java Servlet Programming'

0
 
LVL 5

Expert Comment

by:vemul
ID: 7669695
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:
- To be PAQ'ed and points NOT refunded
Please leave any comments here within the next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

vemul
Cleanup Volunteer
0
 
LVL 5

Accepted Solution

by:
Netminder earned 0 total points
ID: 7714648
Per recommendation, points NOT refunded and question closed.

Netminder
EE Admin
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question