Solved

JSP+Applet

Posted on 2001-07-17
10
458 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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
The viewer will learn how to implement Singleton Design Pattern in Java.

747 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

10 Experts available now in Live!

Get 1:1 Help Now