I have been working (and stubbling) on a website for a while. A major problem that I have is to pass data between the server and client. From client to server I often pass data from forms, but when not doing this, I try to use jquery $.ajax() calls. With ajax, I am able to reliably pass date from client to server, but I have not yet settled on a reliable methodology to pass data from the server to the client.
To pass data from the server to client, I have looked at the web page at https://www.programmergate.com/pass-data-servlet-jsp/ and have been working with the first suggested method, "Using request attributes". I put together a simple web page using Apache tomcat as my local server with a simple example with 2 tests. All worked fine. [Note: the full version of the serlvet and the 2 JSP pages are attached. I can make the full example available if necessary.]
In test case 1, the servlet calls: . On the client side, the JSP code is:
Test case 1 works in all cases.
In test case 2, the JSP page has a form. The action for the form is to pass an email address entered in the form to the servlet. The servlet does a getParameter to read the value passed and then saves the value in a javabean. The servlet fetches the java bean value and passes the value by setting a request attribute as follows:
On the client side, the JSP code is:
Test case 2 works in it's original state.
Can anyone explain this behavior or suggest what is wrong?
Please consider this topic as closed. I may re-post it in the near future, but I think it may be revolved already. My explanation follows. If reading this, you are probably better off leaving this topic now.
For the curious, I have an unusual set of events in the past 6 hours and my explanation for closing this follows.
Late last night, I wrote up this topic. I thought I hit the 'submit' button (actually, I'm 99.99% sure I did hit the submit button). I woke up early this morning and was anxious to see if anyone had responded. So I got back to my desk and looked at 'my posts'. The most recent thread I found was from last week. I realized that THIS topic had not been posted, so I hit the 'submit' button again and verified that it got posted.
I then reviewed and found a new reply had been posted for the topic that I posted last week. It was excellent guidance for me and I plan to implement the suggestion. I am hopeful that by following the suggestion and restructuring the control of my test website, it will resolve many issues that I have, including the problem documented in this thread.
Had I read the update to last weeks topic first, I never would have posted this thread. My apologies.
If it turns out that the underlying cause is not fixed when I restructure my sample web site, I will then re-open this or more likely, just recreate it.