Solved

JSP+Applet

Posted on 2001-07-17
10
463 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
  • 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
 
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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error with Java/Cache JDBC Classpath 2 31
ArrayIndexOutOfBoundException 9 68
how do i compare an object based on two fields 6 49
Spring Framework HTTPSession management 1 24
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now