Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2005

Tip: Looking for answers? Try searching our database.

sevlet postback variable

Thread view: 
javerra - 14 Dec 2005 17:35 GMT
I am still fairly new to servlet devlopment.  Is there anything similar
to the ispostback variable that is in ".net" in the servlet api.  I am
just looking for some suggestions and guidance.  My research has turned
up squat.  Thanks. :)
Liming - 14 Dec 2005 20:43 GMT
i'm not an expert but i don't think there is.

Though using JSF, I was able to achive it by

In everypage, i added an hidden field

<h:inputHidden id="postback" value="unique_pageName" />

and I have a IsPostBack method.. first I get the value of the
"postback" id on the current page and then I check in request parameter
for value the value of the "postback". If there is and it's the same,
it's a postback. If there is no such id in request or the value of the
request is different from the value of "postback" on the current page,
then it's not a post back.
Chris Smith - 15 Dec 2005 04:25 GMT
> I am still fairly new to servlet devlopment.  Is there anything similar
> to the ispostback variable that is in ".net" in the servlet api.  I am
> just looking for some suggestions and guidance.  My research has turned
> up squat.  Thanks. :)

Not exactly.  A few things worth noting are:

ASP.NET is doing some behind-the-scenes magic here.  Since the Servlet
API is intended to be close to a one-to-one Java mapping of the HTTP
protocol, the same magic isn't provided in servlets by default.  You
could very easily reproduce it with a hidden form parameter, as Liming
mentioned.

The other thing about ASP.NET, though, is that it's designed for your to
put all your code into JSPs.  In Java, this is considered extremely poor
form.  If you look at JavaServer Faces (just to pick one example of an
application-level framework for web applications in Java... all the
other major options share this basic characteristic as well), you'll
find that you are encouraged to put processing code into event
listeners, and limit your JSP pages to the user interface.  In a sense,
your "IsPostback" variable is the very fact that you're in a JSP to
begin with.  Things that you would only do if IsPostback is true in
ASP.NET are done in event handlers.  Things that you'd only do if
IsPostback is false would be done in the event handler that is about to
forward to this page, or in the implementation of the JSF component, or
in a bound backing bean method or property.

Give it a shot.  It really makes sense, as you don't end up mixing
processing and display code in the same place; but it is a little
different.

Signature

www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.