Hi,
I am following the tutorial Writing your own Guacamole application.
How can i pass attributes in the "HttpServletRequest request" of the servlet "TutorialGuacamoleTunnelServlet" before creating the tunnel in the client?
because i want to pass the protocol and the hostname from the html in the servlet request!
...
<body>
<!-- Guacamole --><scripttype="text/javascript"src="guacamole-common-js/all.min.js"></script><!-- Display --><divid="display"></div><!-- Init --><scripttype="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
//************
//** I guess here
//***************
// Instantiate client, using an HTTP tunnel for communications.
var guac = new Guacamole.Client(
new Guacamole.HTTPTunnel("tunnel")
);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
/* ]]> */ </script></body>
...
Last edit: beginnerGuac 2015-04-16
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
<!-- Guacamole --><scripttype="text/javascript"src="guacamole-common-js/all.min.js"></script><!-- Display --><ahref="test.html"></a><divid="display"></div><!-- Init --><scripttype="text/javascript"> /* <![CDATA[ */
// Get display div from document
var display = document.getElementById("display");
// Instantiate client, using an HTTP tunnel for communications.
var tunnel = new Guacamole.HTTPTunnel("tunnel");
// here
tunnel.setAttribute("protocol","ssh");
var guac = new Guacamole.Client(tunnel);
// Add client to display div
display.appendChild(guac.getDisplay().getElement());
// Error handler
guac.onerror = function(error) {
alert(error);
};
// Connect
guac.connect();
// Disconnect on close
window.onunload = function() {
guac.disconnect();
}
</script>
And in the servlet i added :
String protocol = (String) request.getAttribute("protocol");
but it doesn't work!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There is no setAttribute() on the JavaScript tunnel object, and attributes really aren't part of HTTP - they're specific to Java servlets. You can use them ... but not as a means of communicating with an HTTP client like the JavaScript HTTP tunnel.
All current tunnel implementations for Guacamole accept data given to connect() in the form of URL encoded parameter/value pairs, separated by "&", just like a normal HTTP url. For example:
Hi,
I am following the tutorial Writing your own Guacamole application.
How can i pass attributes in the "HttpServletRequest request" of the servlet "TutorialGuacamoleTunnelServlet" before creating the tunnel in the client?
because i want to pass the protocol and the hostname from the html in the servlet request!
...
<body>
//************
//** I guess here
//***************
Last edit: beginnerGuac 2015-04-16
i added this line :
// here
tunnel.setAttribute("protocol","ssh");
And in the servlet i added :
String protocol = (String) request.getAttribute("protocol");
but it doesn't work!
There is no setAttribute() on the JavaScript tunnel object, and attributes really aren't part of HTTP - they're specific to Java servlets. You can use them ... but not as a means of communicating with an HTTP client like the JavaScript HTTP tunnel.
You want to use HTTP parameters. You access those via request.getParameter() within Java, and you can pass them to the tunnel via the connect() function: http://guac-dev.org/doc/guacamole-common-js/symbols/Guacamole.Tunnel.html#connect
All current tunnel implementations for Guacamole accept data given to connect() in the form of URL encoded parameter/value pairs, separated by "&", just like a normal HTTP url. For example:
EDIT:
... and the Guacamole.Client object's connect() function provides the same mechanism, as it just invokes connect() on the underlying tunnel: http://guac-dev.org/doc/guacamole-common-js/symbols/Guacamole.Client.html#connect
Last edit: Michael Jumper 2015-04-16
Thank you, it works.