Hello Everybody,

Right, so I would like to see whether I can store a string in my session and send that over to my database.
For example, in a function that I have produced, I would like that function to return a string called "first step", I would like to send that string in a session to my JSP page that will in turn give that string to the servlet to enter to my database, any ideas please?

I have read about using an input hidden field, but I have not had all the required information to start coding it that way. Any help is much appreciated.

Thank you

I believe that the session value is stored in the server side (possible HTTPSession or whatever it is called). What you are looking for is to send a new value to the server, not manipulating session value from the client side. If you are going to use hidden field, just put the hidden field specify 'name' property inside the form that you may also have your session ID hidden as well. If a user submit the form, then your server side would be able to get the hidden value you want.

Note that JSP pages are used with Java, which is not the same as JavaScript.

so, if I have an input field say

<FORM ACTION="GetSession.jsp" METHOD="post">
            <input type="text" name="text1">
            <input type="hidden" name="hidden" 
                value="<%= text%>">
            <input type="submit" value="Set Hidden Text">
        </FORM>

How can ( in javascript) a function send this session to the Servlet?

Please clarify your answers when replying

I believe that the session value is stored in the server side (possible HTTPSession or whatever it is called). What you are looking for is to send a new value to the server, not manipulating session value from the client side. If you are going to use hidden field, just put the hidden field specify 'name' property inside the form that you may also have your session ID hidden as well. If a user submit the form, then your server side would be able to get the hidden value you want.

Taywin, your response is not very clear to me. How would the input hidden be called, I assume this is a form, how can this be implemented, may you please clarify

Note that JSP pages are used with Java, which is not the same as JavaScript.

Thank you :) I am aware of the difference

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.