Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the java webstart problem

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces "how to solve the java webstart problem". In the daily operation, I believe that many people have doubts about how to solve the java webstart problem. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for everyone to answer the doubt of "how to solve the java webstart problem"! Next, please follow the editor to study!

Several technical problems encountered at that time were:

1. Pass the relevant parameters from web to application

Solution: use dynamic jnlp files (jsp to implement jnlp), and use the following method of passing parameters

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:

Arg1argument >

Arg2argument >

Application-desc >

two。 How to send the result of application processing back to web server

The solution is to use URLConnection with web url from jnlp (for a background servlet address), sessionID (to identify the current user, permissions, etc.) to create a new url object and pass data between application and web server through it. Find the current user from the session listener through sessionid in the servlet in the background

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 (dosages null) dos.close ()

If (displaying null) dis.close ()

}

}

Backend 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)

}

}

Digital signature of 3.jar packet

4.java webstart cache problem is: 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 the

(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.

At this point, the study of "how to solve the java webstart problem" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report