Skip to content
Advertisement

Sending request.setAttribute?

What I am trying to do is read file and send the text to jsp

first, I read the context of my text file from fileGet.java. Then using request.setAttribute(“chat”, chat), I want to send the context to Live_index6.jsp

However, as I use request.getAttribute(“chat”) in Live_index6.jsp to receive the data, it kept print “null”

I checked that request.getAtrribute successfully printed the data I wanted in fileController.java, but it does not in Live_index6.jsp

I searched internet and it said code in controller

JavaScript

will send the request data to place where I directed, which is str == “Live_index6.jsp” that I setted.

can you guys please check my code and what is the problem?

Thank you so much!

this is my Live_index6.jsp

JavaScript

my FileController.java

JavaScript

My fileGet.java

JavaScript

Advertisement

Answer

I faced same problem and to solve it I used HttpSession instead of request and response.sendRedirect instead of requestDispatcher this is the code that I used, you need only to reform it

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement