亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

java webstart

發布時間:2021-07-05 16:01:44 來源:億速云 閱讀:127 作者:chen 欄目:編程語言

本篇內容主要講解“java webstart”,感興趣的朋友不妨來看看。本文介紹的方法操作簡單快捷,實用性強。下面就讓小編來帶大家學習“java webstart”吧!

最近做了一個java webstart的項目,java webstart用起來很簡單,在做的過程中,也碰到些技術性的問題。比如如何生成動態的jnlp等問題,在解決相關問題的同時,在解決問題的時候,查看最多的還是官方提供的文檔及資料,以及到sun的webstart上找到相關的解決辦法,

當時碰到的幾個技術問題是:

1.從web傳遞相關的參數給application,

  解決辦法:用動態jnlp文件(jsp實現jnlp),同時用到如下傳參辦法   

application-desc Element

The application element indicates that the JNLP file is launching an application (as opposed to an applet). The application element has an optional attribute, main-class, which can be used to specify the name of the application's main class, i.e., the class that contains the public static void main(String argv[]) method where execution must begin.

The main-class attribute can be omitted if the first JAR file specified in the JNLP file contains a manifest file containing the main class.

Arguments can be specified to the application by including one or more nested argument elements. For example:

<application-desc main-class="Main">
<argument>arg1argument>
<argument>arg2argument>
application-desc>

2.如何將application處理的結果傳回給web server

解決辦法,用URLConnection結合從jnlp中傳來的web url (為一個后臺處理的servlet地址),sessionID(用于識別當前用戶,權限等判斷)去創建一個新的url對象,并通過它在application和web server之間傳遞數據。在后臺的servlet中通過sessionid,從session listener中找到當前用戶,

  private String getStringPostRequest(String command) throws Exception {
DataOutputStream dos=null;
ObjectInputStream dis=null;
try {
URLConnection urlConn = new URL(webServerStr).openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setAllowUserInteraction(false);
urlConn.setUseCaches(false);
urlConn.setRequestProperty(
"Content-Type",
"application/x-www-form-urlencoded");

dos = new DataOutputStream(urlConn.getOutputStream());
dos.writeBytes(command + "&sessionId=" + this.sessionId);
dos.close();
// read input from servlet
dis =
new ObjectInputStream(urlConn.getInputStream());
String ret = dis.readObject().toString();
dis.close();
return ret;
} catch (Exception e) {
throw e;
} finally{
if ( dos!=null) dos.close();
if ( dis!=null) dis.close();
}
}

后臺sevlet:

public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{
HttpSession hSession = request.getSession();
System.out.println("Application:" + hSession.getId());
if(MyListener.getSessionById(request.getParameter("sessionId")) != null)
hSession = MyListener.getSessionById(request.getParameter("sessionId"));
System.out.println("OK" + hSession);

..............}

sessionlistener:

import java.util.HashMap;
import java.util.Map;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.*;

public class SessionsListener
implements ServletContextListener, HttpSessionListener
{

static Map map = new HashMap();

public SessionsListener()
{
}

public void contextInitialized(ServletContextEvent servletcontextevent)
{
}

public void contextDestroyed(ServletContextEvent servletcontextevent)
{
}

public void sessionCreated(HttpSessionEvent httpsessionevent)
{
HttpSession httpsession = httpsessionevent.getSession();
map.put(httpsession.getId(), httpsession);
}

public void sessionDestroyed(HttpSessionEvent httpsessionevent)
{
HttpSession httpsession = httpsessionevent.getSession();
map.remove(httpsession.getId());
}

public static HttpSession getSessionById(String s)
{
return (HttpSession)map.get(s);
}

}

3.jar包數字簽名問題

http://www-900.ibm.com/developerWorks/cn/java/l-webstart/index.shtml

4.java webstart cache問題即:JNLP file caching

http://forum.java.sun.com/thread.jspa?forumID=38&threadID=556847

(1)

If you remove the href= parameter from the jnlp tag, Java Web Start 1.4.2 will not cache the jnlp file.
1.5.0 still will, but if you also remove theit will not mater, since you will not be able to launch it from a shortcut or from the Cache Viewer.

(2)

It seems the issue is with generated JNLP files.

Try the following:

response.addDateHeader("Date", Calendar.getInstance().getTime().getTime());
response.addDateHeader("Last-Modified", Calendar.getInstance().getTime().getTime());


Seems to have solved the problem for us.

下面是幾個webstart的資料網址:

http://www-900.ibm.com/developerWorks/cn/java/l-webstart/index.shtml

http://java.sun.com/j2se/1.4.2/docs/guide/jws/developersguide/contents.html

http://forum.java.sun.com/forum.jspa?forumID=38

到此,相信大家對“java webstart”有了更深的了解,不妨來實際操作一番吧!這里是億速云網站,更多相關內容可以進入相關頻道進行查詢,關注我們,繼續學習!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

东乡县| 龙川县| 盖州市| 荣昌县| 新野县| 湖州市| 乌鲁木齐县| 同仁县| 丘北县| 乐清市| 安多县| 乌拉特后旗| 涞水县| 平潭县| 湖南省| 巨鹿县| 于都县| 綦江县| 新龙县| 昭苏县| 河南省| 金寨县| 屏南县| 娄底市| 革吉县| 海盐县| 云阳县| 武隆县| 剑阁县| 营山县| 宝清县| 雷州市| 汾阳市| 澎湖县| 古丈县| 林甸县| 诸暨市| 赤水市| 新龙县| 天全县| 肃宁县|