Is it possible that, in a
JSP page, I include a javascript section like
*****************
<% import %>
<!-- some JSP and html portion -->
<input type="button" onClick="verify()"/>
<script>
function verify() {
var name = document.getElementbyID("name");
var street = ...
<% Contact contact = new Contact(name, street);
session.setAttribute("contact", contact);
%>
window.open("/newAction");
}
</script>
******************
What I want to do is --- I want to create a
java object inside the javascript, and pass it to a new action page. On the new action page, it retrieves the object from session, then use this object's data to access database and finally get the results and display it. Basically I need to use the client side information (what user selects) and I want to somehow pass it to a
struts action or
servlet or JSP by passing the data in a session. But I don't know if this idea is valid -- can I create java object inside javascript ? and can I embed java code inside javascript ? If I can't how can I save a client side DOM info into session ? Note -- I don't want to submit the whole thing to server by using a submit button. I have separate buttons to handle that, this is just a verify button in the middle stage.