Solved

JSP+Applet

Posted on 2001-07-17
10
476 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
Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I had a project requirement for a displaying a user workbench .This workbench would consist multiple data grids .In each grid the user will be able to see a large number of data. These data grids should allow the user to 1. Sort 2. Export the …
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

730 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