當時碰到的幾個技術問題是:
1.從web傳遞相關的參數給application,
解決方法:用動態jnlp檔(jsp實作jnlp),同時使用如下傳參方法
application-desc
ElementThe 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 static void main(String argv[]) method where execution must begin.
Themain-class
Arguments can be specified to the application by including one or more nestedattribute can be omitted if the first JAR file specified in the JNLP file contains a manifest file containing the
mainclass.
argument elements. For example:
#argumentelements. For example:argument
<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;
InputStream dis=null;##DataOutputStream dos=null;
InputStream dis=null;# #try {
URLConnection urlConn = new URL(webServerStr).openConnection();
urlConn.setDoOutput(true);
urlConn.setDoInput(true);
urlConn.setAllowUserInteraction(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 ( dis!=null) dis.close();
}}
後台sevlet:
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException
{##HttpSession#Httion ();
System.out.println("Application:" hSession.getId());
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.http.*;
public class SessionsListener
{
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());
}
{
return (HttpSession)map.get(s);}
#}
3.jar包數位簽章問題
4.java webstart cache問題即:JNLP file caching
#http://forum.java.sun.com/thread.jspa?forumID =38&threadID=556847
1.5.0 still will, but if you also remove the
(2)
It seems the issue is with generated JNLP files.
Try the following:
以上是java webstart問題怎麼解決的詳細內容。更多資訊請關注PHP中文網其他相關文章!