File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes submitting page to itself Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "submitting page to itself" Watch "submitting page to itself" New topic

submitting page to itself

Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
Hi guys,
I have a JSP with a form in it, the action page does not do much so I was wondering, is it possible to make the action page the calling page? If yes then how?

All right brain, you don't like me and I don't like you, but let's just do this one thing so I can get back to killing you with beer.<br /> <br />- Homer Simpson
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63548

is it possible to make the action page the calling page?

Could you be more explicit about what you mean by "action" and "calling" pages?
(If you just want the page to submit to itself using the same URL, I think that leaving off the action attribute of the form tag may accomplish that, but that might be a better question for the HTML forum).

[Asking smart questions] [About Bear] [Books by Bear]
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

So you want a something like:


Well, PHP users do this a lot because PHP is like using JSP without actual Servlets. This is not a good idea, but can be done. You will need a lot of logic and scriplets in your JSP page to detmerine when to do what with any data you may or may not have. A better approach would be the following:
I have a form called employeelookup.jsp. It begins with a text field for the employee ID. When I click the Lookup button I call a Servlet that gets the employee info from a DB and fills an EmployeeBean with some initial data. I then forward back to employeelookup.jsp.
I have another form on that same page that is encoumpassed with jstl's c:test= where I test for the presence of that EmployeeBean. If it exists, I display some info about the employee for verification and also provide a Continue button to move on to the Call Log form.
[ January 16, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
Alex Kravets
Ranch Hand

Joined: Jan 24, 2001
Posts: 476
thanks, but actually after snooping on google i got it:


Gregg Bolinger

One of these days, I am going to teach a 'How to search the web using Google' class

I searched google before I read your signature LOL
[ January 16, 2004: Message edited by: Alex Kravets ]
[ January 16, 2004: Message edited by: Alex Kravets ]
I agree. Here's the link:
subject: submitting page to itself
It's not a secret anymore!