hi all , I created a servlet,from the servlet i posting data to the jsp. But all the data is public i.e user can be able to see the data in the url. I tried using post method from the servlet still i can be able to see all the data in the url. I dont want the user should see the data in the url. I read something like RequestDispatcher but its not working. how to solve this.
You haven't given us anywhere near enough information. How is the servlet being invoked? What does the getUsernameDetails() method do? And it appears that you are not posting from this servlet, but to it.
Also, a post will not cause the doGet() method to be called. [ November 21, 2008: Message edited by: Bear Bibeault ]
hi, I can set the session variable in the servlet and get the variable in a jsp using response.sendredirect method.
and in get the varaible
i feel if two customers tried with the same time he may get wrong ouput or there will be some issue with lots of sessions. I think i clean up the session variable somewhere so that it should not be a problem.am i right or correct if i am wrong somewhere .
I am not exactly clear on what you are asking. I do nto see any instance variables in your servlet though, so why do you think there may be a problem with the session if more than one user access your servlet? [ November 24, 2008: Message edited by: Bosun Bello ]
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Khalid said. hi , i mean i can see this parameter in the url value=Valid&designation=Manager&sal=2000
and my query is i dont want to see them in the url
Are you sending a redirect to the client?
You initial form posts the data to the server and you wont see the user parameter in the url. Now when your request reaches the server What is you requirement? If you send a redirect, then yes the parameters will be visible in the client's browser as you are constructing the url and adding the parameters to the url as query string. The question is , do you really require a redirect? Cant you use requestDispatcher.forward()? If you use the forward or include (which happens on server side and transperent to end user) you query string will not be visible in the browser.
Joined: Nov 19, 2008
Amol Nayak says You initial form posts the data to the server and you wont see the user parameter in the url. Now when your request reaches the server What is you requirement?
If you send a redirect, then yes the parameters will be visible in the client's browser as you are constructing the url and adding the parameters to the url as query string.
I solved this query string issue by
get the variable like request.getAttribute("result") in jsp and its working fine.
The problem with the above code is i couldnt be able to invoke the DisplayData.jsp.
i read in internet
The forward is made server-side, meaning the user will still see the first URL he entered. Also, you keep the same ~Request object when the second URL is loaded, meaning you can share data using attributes.
The redirect is actually a HTTP response sent to the user asking him to go to another URL, meaning that the URL in his address bar will change. The second URL is then a fully new request.
so i tried this code
and in get the varaible
The storing the session variables concept is working.But i feel somewhere session lost or session exists or may be some prob will arise with session so i feel dispatcher.forward method is good to solve the my query.
As i mentioned if i use dispatcher.forward i cant be able to invoke the jsp?No idea how to solve this.
Joined: Oct 26, 2006
Khalid said: As i mentioned if i use dispatcher.forward i cant be able to invoke the jsp?No idea how to solve this.
What exactly is happening?
subject: Problem while posting data from a servlet.