hello everyone i have to show a page index.jsp and in this page i have used the onload submit
the above is my jsp code and i have printed hello on this page. But when i hit the URL localhost:8090/tempmonitoringsystem/index.jsp.
It shows index.jsp for nanosec den went away to the folowing URL localhost:8090/tempmonitoringsystem/tempmonitor and i don't know where it is redirecting to.
I am Attaching my servlet code as well as xml code.
tarunv Verma wrote:I required onload = submit because i have to show some dynamic images when the page opens.
That makes no sense to me at all. I agree with Jk -- you're doing it wrong.
Why not back up and instead of getting us to try and help you do it wrong, describe what you are actually trying to accomplish so we can help you do it right.
May be i am doing it in a wrong way. I will explain you my problem. Please have a look at it.
I have some text file which keep on changing after 5 mins. On basis on those files i have to make dynamic image for each file. When the user open the page he should see all the images without clicking anywhere but when he clicks on the image a log file should be available for downloading. I hope that has given you a good idea about my problem.
You might also read this article on best-practice web application structure.
Joined: Dec 14, 2011
Jk Robbins wrote:Ok, let me see if I understand. I'm thinking something like this:
Send a request to a servlet which will determine which images to display.
Put the image file names into a collection and send it to a jsp to display the images as links.
Now you can either use the links to take you to the log page, or initiate a download, or you can use Ajax to capture the click event on any image and use that to fetch the log.
I hope I'm understanding the requirements correctly.
Thats what i want to know how to request servlet without window=onload. I was using .net technology before in that there is a function page_load() in which we can apply what we want at loading of page. So i am looking similar kind of thing. Hope to see your reply on that.
That will send a GET request to the servlet. You can include parameters if needed using init-params in the web.xml or in the URL using the "?key=value&" format. Now the servlet can build the response and send it whatever page you designate with the RequestDispatcher.
I think your mistake is thinking that you need to call a page first and then let that page call the servlet. It doesn't need to be done that way, and in fact, shouldn't be done that way.
tarunv Verma wrote:Thats what i want to know how to request servlet without window=onload. I was using .net technology before in that there is a function page_load() in which we can apply what we want at loading of page. So i am looking similar kind of thing. Hope to see your reply on that.
That might have been the way to work with .Net, but it is not the way to work with Java web apps. You're just going to create a big old mess.
Pay attention to what you've been told here and in the linked articles.
You do not hit the JSP first. You hit a servlet first.