How to make the applet and servlet two-way communication - follow-up?

xiaoxiao2021-03-06  74

Question 7.1 APPLET can not be two-way communication with Struts's action, because now web application uses MVC

Solve: Yes, there is a request parameter in the Execute method in the action, using the same as the servlet.

?

Question 7.2: After the two-way communication issues are solved, in practical applications, such as what I have encountered: web applications use third-party packages, it implements * .do request forwarding, that is, inherits Struts The ActionServlet, which this ActionServlet will verify that the user has already logged in, so use the URL in the applet to directly point to the Action, this connection is not the corresponding user cookie in the request header, so it will be reported when the forwarding is implemented: Class below:

?

?

At this time, to call the setRequestProperty method to add the corresponding request header information, how to get the user's cookies? Can be processed: Is the applet to be embedded in JSP, get the user's cookie (String SessionID = Request.getHeader ("cookie") in JSP;), and then use the parameter of the applet to the applet. Other parameters are similar to this. This is a piece of code snippet plus a request head:

?

?

Question 7.3: After the above steps, there is no problem as Applet as Application, but in the web page, it will encounter security issues. For example, this error is encountered:? Solution: This, you need to edit the security policy file, you can Edit it using the JDK deploytool tool. Name and location requirements of the file (quoted 9CBS on a piece of one article): in the author's article "Applet directly access the database" http://www.9cbs.net/develop/read_article.asp?id=15810

The production of Applet policy files is described in one article. There are two ways to make the policy file, one is the PolicyTool tool for the JDK, which provides a graphical interface, allocates permissions for Applet, the other is to directly edit the policy file, and the initiator uses the first way to be more appropriate, skilled, straight The editor is relatively fast. Let's talk about how to edit its strategy files directly. The name of the policy file is ".java.policy", this file must be placed in the user's root directory, under the Windows2000 system, for the operating system where the system is located: / Documents and settings / user name directory, such as my system is installed in the C drive, The user is administrator, then this directory is C: / Documents and Settings / Administrator. ".java.policy" files cannot be created in the Windows2000 graphical interface, you can open a command line window, enter the C: / Documents and Settings / Administrator, create a text file under the graphical interface, such as named java.policy, then use DOS Command C: / Documents and Settings / Administrator> Move Java.Policy .java.policy is OK, then use an editor to open the file, enter the content, the content may be similar to the lower: GRANT {? Permission Java. lang.RuntimePermission "accessClassInPackage.com.microsoft.util";? permission java.lang.RuntimePermission "accessClassInPackage.com.microsoft.jdbc";? permission java.lang.RuntimePermission "accessClassInPackage.com.microsoft.jdbcx";? permission java .NET.SOCKETPERMISSION "192.9.200.52:1433", "Connect";}; saving. The first line to the third line are authority granted to the applet to access three packets, and the fourth line is awarded the authority of the Applet connection 192.9.200.52:1433 address port.

?

?

?

?

For my own problems, I also edited the following policy files: / * Automatically generated on WED AUG 18 15:14:38 CST 2004 * / / * do not edit * /

?

Grant {? permission java.util.propertypermission "http.strictpostedirect", "read, write";

?

?

?

?

?

转载请注明原文地址:https://www.9cbs.com/read-121067.html

New Post(0)