Empty init() methods
I am currently working on and cleaning up (old) Java servlet code that I inherited from another collegue. In a lot of the servlets, I find empty init() methods like:
public void init() {
}As a novice to Java servlets, I have just been reading the First Edition of Jason Hunter's 'Java Servlet Programming' book. There, on page 59 it is stated that every servlet's init() method should call super.init(config) as its first action. I was wondering if I could simply remove the empty init() methods that I encounter in the servlets... If i remove them, the init() method of the superclass will get called... and the behaviour of the superclass init() might be slightly different than an emtpy init() method... isn't it? But I wonder if it will make a big deal for my application...
Are there any possible side effects to expect here? What could probably happen if remove the empty init() methods and consequently start using the init() method from the superclass?
OK. Yesterday, I cleaned up all empty init() methods, now it's time for cleaning up all unnecessary init(ServletConfig cfg) methods. In the servlet code that i inherited from a collegue, I find a lot of servlets containing the following:
public void init(ServletConfig cfg) throws ServletException {
super.init(cfg);
}In the meanwhile, i know that we are using Tomcat 5.5 as a container, so I looked into the Tomcat HttpServlet implementation and I found no init(ServletConfig cfg). I then looked at GenericServlet where i found:
public void init(ServletConfig config) throws ServletException {
this.config = config;
this.init();
}and since the init() method also doesn't do much, i think i can safely remove all
public void init(ServletConfig cfg) throws ServletException {
super.init(cfg);
}methods in our own servlets... since what they do is actually just the same as the init(ServletConfig cfg) method from GenericServlet.
Can somebody who is more experienced in Java Servlets than me confirm?
Thanks!
Bart
Similar Messages
-
The Init() method of abstract pagebean always it excute, and i lost data.
Hi,
I have applicaction to buid in NetBean 6.1 and JDK 1.6 using Visual Web Java Server Pages. This application to present a view that have a 2 calendar component, 1 dropdownlist, button component and table component.
The table component show rows where calendar1.date > date1 and calendar2.date < date2 and estado(DropDownList)= status1
In the init() method of abstractpagebean i set de initial calendar's date that follow
java.util.Calendar dateAntes = GregorianCalendar.getInstance();
java.util.Calendar date = GregorianCalendar.getInstance();
dateAntes.add(java.util.Calendar.MONTH, -1);
GregorianCalendar gc = new GregorianCalendar(2000, 11, 20);
//tablePhaseListener = getSessionBean1().getTablePhaseListener();
calendar1.setSelectedDate(dateAntes.getTime());
calendar2.setSelectedDate(date.getTime());
With this initial dates dates i show the table row thw follow
String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
"requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
"FROM requerimiento,cliente,estado " +
"WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
"AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";
try {
getSessionBean1().getRequerimientoRowSet().setCommand(command);
getSessionBean1().getRequerimientoRowSet().getCommand();
getSessionBean1().getRequerimientoDataProvider().refresh();
} catch (Exception e) {
error("No puede levantar comando");
log("Cannot switch to person " +
estados.getSelected().toString(), e);
The DropDownList implement the ProcessValueChange Event with AutoSubmit On Change properties. At Change choise of DropDown List Component it trigger a event that and execute estados_processValueChange method that to show a table rows accord to the new filter (include the new calendar date if necessary that follow:
String command = "SELECT ALL codreqgmc, fechareq,cliente.nomclie,estado.Descripcion as Estado, " +
"requerimiento.codtecnico, requerimiento.rutclie, requerimiento.codestado " +
"FROM requerimiento,cliente,estado " +
"WHERE requerimiento.rutclie=cliente.rutclie and requerimiento.codestado=estado.codestado and fechareq>=" + "'" + formatoFecha.format(calendar1.getSelectedDate()) + "'" +
"AND fechareq<=" + "'" + formatoFecha.format(calendar2.getSelectedDate()) + "'";
try {
getSessionBean1().getRequerimientoRowSet().setCommand(command + " AND requerimiento.codestado =" + "'" + (String) estados.getSelected() + "'");
getSessionBean1().getRequerimientoRowSet().getCommand();
getSessionBean1().getRequerimientoDataProvider().refresh();
} catch (Exception e) {
error("No puede levantar comando");
log("Cannot switch to person " +
estados.getSelected().toString(), e);
The Table component have a column of checkbox type for select a particular(s) row(s). With a Button it to choose all the rows that has been to set checkbox, in the session bean to save this selected rows and link to another page that show the details about seletec rows.
The Problem
Every time that i press the button, after to the select the rows, for another page showme detail, this page is empty because it execute the init method before the button_action, to re initialize and erase the user selection and lost it
I try with another component that trigger event, por exmaple dropdownlist, and it the same, even to press the pagin in teh table it execute init meth, re-initialize and erase all.
Result prove
1.- I execute the application for first time:
Execute Init()
2.- I Chage choos en the DropDownList
Execute Init() and
after estado_processValueChange()
3.- I change choos again in the DropDownList
Execute Init() and
after estado_processValueChange()
4.- I press pagin button in table
Execute Init()
5.- I press button detail, for detail
Execute Init() ----> I reinitialize and lost the user select.
after Butoon_action
How ia can to preven that every time it execute init(),
Why alway it execute init method?, the init methd() is for initialize application and not RE INTIALIZED
Why is the relation INIT(); PREPROCESS(), PRERENDER(), PROCESSVALUECHANGE, BUTTON_ACTION. What it execute first, what secodn?
I need execute init method only one , at first time
I hope i undertandme, i not native english.
Thank for advanceAnupama,
Do you mean init or wdDoInit? You cannot call the later as well as you cannot call any WD-framework methods that start with "wd" prefix.
By the way, wdDoInit in component controller (do not confuse with custom controller or interface controller) is called before any other method in any controller. So I hardly believe that it is not called when your view become available.
Valery Silaev
SaM Solutions
http://www.sam-solutions.net -
How can i redirect to my jsp page from servlet in init() method..Becoz that servlet is calling while server startsup..so im writing some piece of code in init() method..after that i want to redirect to some jsp page ...is it possible?
using RequestDispatcher..its not possible..becoz
RequestDispatcher rd = sc.getRequestDispatcher("goto.jsp");
rd.foward(req,res);
Here the request and response are null objects..
So mi question can frame as how can i get request/response in servlet's init method()..Hi guys
did any one get a solution for this issue. calling a jsp in the startup of the servlet, i mean in the startup servlet. I do have a same req like i need to call a JSP which does some data reterival and calculations and i am putting the results in the cache. so in the jsp there in no output of HTML. when i use the URLConnection i am getting a error as below.
java.net.SocketException: Unexpected end of file from server
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:707)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:705)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:612)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLCon
nection.java:519)
at com.toysrus.fns.alphablox.Startup.callJSP(Unknown Source)
at com.toysrus.fns.alphablox.Startup.init(Unknown Source)
at org.apache.tomcat.core.ServletWrapper.doInit(ServletWrapper.java:317)
so plz do let me know how to call a jsp in the start up of a servlet.
Thanks
Vidya -
Why there are two init methods?
I copied this code from netbeans for a JApplet.. and it has two init methods
One is public void init() that calls another initComponents() method.
And the initComponents() method has all the components defined in it, and it is private.
I replaced private with public and changed initComponents to init, and then deleted all the init method, it worked that way.
But why there two methods when you can put every thing in single init() method?
The init() method has this code in it:
public void init() {
try {
java.awt.EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
} catch (Exception ex) {
ex.printStackTrace();
}BDLH:
WWJD? Probably code in Ruby, but I digress. No, he would define an abstract base for that boilerplate code:
import java.awt.*;
import java.lang.reflect.*;
import javax.swing.*;
public abstract class AbstractApplet extends JApplet {
public void init() {
try {
EventQueue.invokeAndWait(new Runnable() {
public void run() {
initComponents();
} catch (InterruptedException ex) {
ex.printStackTrace();
} catch (InvocationTargetException ex) {
ex.printStackTrace();
protected abstract void initComponents();
//ditto: start, stop, distroy
} -
LDAP Context Initialization Problem in a Servlet's Init method
Hi
I have a servlet where I am using the InitialDirContext to Initialize context to a LDAP Server. I have created the context as a static variable. I am initializing the context in the init method and am using the same reference in the service method of the servlet. But if the context fails (due to naming exception and time out) in the init method all my requests in the service method will fail. Is there any way to validate the reference before using the same in the service method.
Also what is the best approach to initialize the context in a servlet. Whether to initialize in the service method or the init method.
I would appreciate if anyone can answer the above 2 queries.
Thanks in advace,
AshishIf you want to use threadsafe objects in doPost/doGet there are two common ways to do this.
First, create the object in doPost/doGet. This may get expensive depending on the object, but it is 'easy' code and works.
The second option is to create a pool of objects in the servlet's init() method and to just have doPost/doGet get an object from the pool, use it and return it when done. This take a little more work to code, but the overhead of creating objects is almost eliminated. Look at jakarta/apache commons pool for a quick way to do this.
If you create on object in init() and use it in doPost/doGet, any time you get two request for the same servlet at the same time you will have synchronization issues that will usually cause problems. There is one instance of each Servlet, so all request for that servlet go through the single instance. Anything in doPost/doGet must be threadsafe. -
How to call server event in DO INIT method of view
Folks,
I have declared a server event in the view and when I am trying to call that event in DO INIT method of view , it is not firing the event .
<i><b>
public void wdDoInit()
//@@begin wdDoInit()
// set icon file names
wdContext.currentContextElement().setIconLeftArrow("topLvlScrollerLeft.gif");
wdContext.currentContextElement().setIconRightArrow("topLvlScrollerRight.gif");
// hide display when errors during startup
if(wdContext.currentContextElement().getErrorDuringInit())
wdThis.wdFirePlugOutEmpty();
wdThis.wdGetDaylyChangeModeAction();</b></i>I have created a action event
<i><b> public void onActionDaylyChangeMode(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionDaylyChangeMode(ServerEvent)
wdThis.wdGetVcCatRecordEntryInterfaceController().blcEvent(VcCatRecordEntry.ACTION_CHANGE_MODE);
wdContext.currentContextElement().setSelectedTab("TabCatRecordEntryDay");
wdContext.currentContextElement().setTemp("Changed Tab");
//@@end
}</b></i> -
How to write custom prerender or init method?
some ide provide override prerender() and init() methods,i can use this methods,
i use differnt ide but i didnt find prerender and init methods ,so i try to write these but i couldnt.
i did ;
1) write phaselistener
2) and extends my beans with phaselistener
public class phases implements PhaseListener {
public phases() {
public void init() {
System.out.println("/******************phase****init*****************************");
public void afterPhase(PhaseEvent phaseEvent) {
public void beforePhase(PhaseEvent event) {
if (event.getPhaseId()==PhaseId.RESTORE_VIEW) {/// this mean is page init
init();
protected boolean isPostBack() {
if (getFacesContext().getRenderResponse())
return false;
else
return true;
and my bean is ;
public class login extends phases {
@Override
public void init() {
System.out.println("/**********************init*****************************");
but nothing (didnt enter the init method);;
pls How can i do this?
Edited by: ermanbas on Jun 13, 2009 9:16 PM
Edited by: ermanbas on Jun 13, 2009 9:17 PMThat's why it sucks to be tied up to an ide feature. Do not extend your beans from a phaselistener. You need sth like;
http://cagataycivici.wordpress.com/2006/06/06/managed_beans_aware_of_the/
Edited by: CagatayCivici on Jun 16, 2009 4:06 PM -
Init method in Weblogic 5.1 gives problem
I have used init method in 4.5
the same method gives problem in 5.1
C:\weblogic\myserver\classfiles\jsp_servlet\_addcontract.java:89: The method void init(javax.servlet.ServletConfig) declared in class jsp_servlet._addcontract cannot override the final method of the same signature declared in class weblogic.servlet.jsp.JspBase. Final methods cannot be overridden.
probably occurred due to an error in /addContract.jsp line 11:
Use jspInit method.
harish <[email protected]> wrote:
> I have used init method in 4.5
> the same method gives problem in 5.1
> C:\weblogic\myserver\classfiles\jsp_servlet\_addcontract.java:89: The method void init(javax.servlet.ServletConfig) declared in class jsp_servlet._addcontract cannot override the final method of the same signature declared in class weblogic.servlet.jsp.JspBase. Final methods cannot be overridden.
> probably occurred due to an error in /addContract.jsp line 11:
Dimitri
-
Portal runtime error exception ID: error in init method
Hi Experts
I am getting the portal runtime error http://<fqdn>:<port>/irj/portal, can anybody suggest me what to do.
"Portal runtime error.
An exception occurred while processing your request. Send the exception ID to your portal administrator.
Exception ID: 02:27_06/09/10_68650050"
Here is the log file
02:27_06/09/10_68650050
[EXCEPTION]
com.sapportals.portal.prt.component.PortalComponentException: Error in init method
Component : com.sap.netweaver.coll.appl.ui.room.CollaborationDetailedNavigation
at com.sapportals.portal.prt.component.PortalComponentContext.init(PortalComponentContext.java:251)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.refresh(PortalComponentContextItem.java:271)
at com.sapportals.portal.prt.core.broker.PortalComponentContextItem.getContext(PortalComponentContextItem.java:316)
at com.sapportals.portal.prt.component.PortalComponentRequest.getComponentContext(PortalComponentRequest.java:387)
at com.sapportals.portal.pb.PageBuilder.createIviewProfile(PageBuilder.java:443)
at com.sapportals.portal.pb.PageBuilder.createiView(PageBuilder.java:391)
at com.sapportals.portal.pb.PageBuilder.createAndAddiViews(PageBuilder.java:233)
at com.sapportals.portal.pb.PageBuilder.doOnNodeReady(PageBuilder.java:635)
at com.sapportals.portal.prt.component.AbstractPortalComponent.handleEvent(AbstractPortalComponent.java:388)
at com.sapportals.portal.pb.PageBuilder.handleEvent(PageBuilder.java:815)
at com.sapportals.portal.prt.component.CachablePortalComponent.handleEvent(CachablePortalComponent.java:703)
at com.sapportals.portal.prt.pom.ComponentNode.handleEvent(ComponentNode.java:252)
at com.sapportals.portal.prt.pom.PortalNode.fireEventOnNode(PortalNode.java:368)
at com.sapportals.portal.prt.pom.AbstractNode.addChildNode(AbstractNode.java:340)
at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:642)
at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:235)
at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:523)
at java.security.AccessController.doPrivileged(Native Method)
at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:412)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:104)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:176)
Caused by: com.sapportals.portal.prt.core.broker.PortalComponentInstantiationException: Could not instantiate implementation class com.sapportals.portal.navigation.CollaborationNavTree of Portal Component com.sap.netweaver.coll.appl.ui.room.CollaborationDetailedNavigation because: Could not instantiate implementation class
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getInstanceInternal(PortalComponentItemFacade.java:269)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getComponentInstance(PortalComponentItemFacade.java:160)
at com.sapportals.portal.prt.core.broker.PortalComponentItem.getComponentInstance(PortalComponentItem.java:732)
at com.sapportals.portal.prt.component.PortalComponentContext.getComponent(PortalComponentContext.java:103)
at com.sapportals.portal.prt.component.PortalComponentContext.init(PortalComponentContext.java:242)
... 35 more
Caused by: com.sapportals.portal.prt.runtime.PortalRuntimeException: [PortalApplicationItem._prepare]: com.sap.netweaver.coll.appl.ui.room
at com.sapportals.portal.prt.core.broker.PortalApplicationItem.prepare(PortalApplicationItem.java:427)
at com.sapportals.portal.prt.core.broker.PortalApplicationItem._refresh(PortalApplicationItem.java:507)
at com.sapportals.portal.prt.core.broker.PortalApplicationItem.getCoreLoader(PortalApplicationItem.java:1360)
at com.sapportals.portal.prt.core.broker.PortalComponentItem.getClassLoader(PortalComponentItem.java:569)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getClassLoader(PortalComponentItemFacade.java:102)
at com.sapportals.portal.prt.core.broker.PortalComponentItemFacade.getInstanceInternal(PortalComponentItemFacade.java:228)
... 39 more
Caused by: com.sapportals.portal.prt.runtime.PortalRuntimeException: [PortalApplicationItem._prepare]: com.sap.netweaver.bc.rf.service
at com.sapportals.portal.prt.core.broker.PortalApplicationItem.prepare(PortalApplicationItem.java:427)
at com.sapportals.portal.prt.core.broker.PortalApplicationItem.prepare(PortalApplicationItem.java:387)
... 44 more
Caused by: com.sapportals.portal.prt.runtime.PortalRuntimeException: Exception during start of application: SAPJ2EE::library:signature_lib
at com.sapportals.portal.prt.core.broker.SAPJ2EEApplicationItem.prepare(SAPJ2EEApplicationItem.java:323)
at com.sapportals.portal.prt.core.broker.PortalApplicationItem.prepare(PortalApplicationItem.java:387)
... 45 more
Caused by: com.sapportals.portal.prt.core.broker.SAPJ2EELibraryNotFoundException: Could not find Library SAPJ2EE::library:signature_lib
at com.sapportals.portal.prt.core.broker.SAPJ2EEApplicationItem.prepare(SAPJ2EEApplicationItem.java:277)
... 46 more. . .
Thanks in advance
UdayHi Tobias
Thanks for your response, i can able to access /nwa. The trace file while is posted got from /nwa.
I have restarted the portal. Can you please tell me where can we check the errors when portal started?
Thanks in advance
Uday -
Let's just say I want to write a startup class that initilizes a servlet,
(just like ServletStartup class). How would I do this without using the
URLConnection class?
Thanks
c00ler wrote:
Hey guys,
Studying JDBC & Java by O'Reilly. Old book, very old. You'd be better off with the Sun JDBC tutorial. Google for it.
init() method is not really explained in the book and i'm kind of stuck. As far as i understand it's used to initialise servlet before its execution right? O'Reilly uses it to connect to the database (i'm find with connection part), problem is i don't understand why i can't connect through proccessRequest() method and I can't actually find the init() method within servlet...unless of course i write my own one. There is code offered by O'Reilly:
Terrible form. More evidence of just how out of date this book is. No one would write a servlet to do this now.
Book was published quite a few years ago...is there different implementation to this?
Also for some reason Class.forName().newInstance() throws unidentified error if i use SQLException (even though java.sql.* is there), but works fine with Exception...any ideas???Not unidentified if you look at the javadocs for Class - it throws ClassNotFoundException, among others.
You don't have to call newInstance() - Class.forName() is sufficient for registering the driver class.
% -
Servlet init() method called multiple times
We have a Servlet-based application which does lengthy initialization.
We've noticed that when multiple requests arrive,
but the Servlet's init() method has not returned yet
for the first request, the application server calls init() multiple times.
You can even see this with the Fortune sample
Servlet. Starting the app server and sending 20 or 30
simultaneous requests causes multiple Fortune Servlet init messages to appear in the kjs log.
Why is this? We do not implement SingleThreadModel.
Doesn't the J2EE 1.2 spec say init will be called
only once?
How do we prevent it?
A Startup class which inits our
Servlet?
Or a synchronized block within our init method, with some checks of static member variables
so that the initialization work only happens once?
Or is there some kregedit magic or deployment descriptor change I could make?
Again, it's not a SingleThreadModel issue, so don't
point me there.
This is iAS 6.0 SP4, on Solaris, by the way.Hi
Yes,you are right. In iAS6.0 SP4 When multiple requests arrive,and the Servlet's init() method has not returned yet for the first request, the application server calls init()multiple times. This problem is resolved in iAS 6.5.
There is no kregedit magic that will solve this problem.
Right now the workaround is any of the solution you proposed. Or use iAS6.5. I have tested it with fortune.
Please download it and check with your application.
you can find free download at http://developer.iplanet.com/appserver/testdrive/testdrive_65.html
Thanks -
Init method is called multiple times
Hi,
init method in my servlet is called more than 1 time.
I think it is supposed to be called only 1 time,when the application is loaded.
anything to do with web.xml ???
or else what r the situations that init method is called more than 1 time
thanksHi,
actually I figured out the problem.
I am using logger staements for debugging.
I am also using singlethread model for servlet.
I came to know that it creates multiple instances of servlet...
which inturn calls init method multiple times.
i took out that singlethread model,now it is working perfect.
Thanks -
Backing file init method always called for proxy portlets
Hello,
We are currently using Weblogic Portal 10 MP1. Deployed within our Portal EAR is a local proxy portlet and attached to this proxy portlet is a backing file, which currently implements the init() and prerender() methods from the backing interface.
When this is placed in a page that is within a desktop, the init() method is always invoked no matter which page you access within the desktop. As I understand it from the documentation, if you have "tree optimization" turned on, then the init() method will only be called when rendering the actual page the proxy portlet is in. But this doesn't seem to be the case. However, if I define a standard Java portlet within the EAR and attach a backing file, then the init() follows the rules when tree optimization is turned on or off.
Does anyone know if this is a defect within the portal framework, or is this expected and proxy portlets do not follow this rule?
And I guess, if it is a defect or known limitation, is there a possible workaround? I assume the simplest workaround will be to move the logic into the prerender() method.
Regards,
JonathanHello Jonathan,
Tree optimization is a tricky thing- some portlets may still be initialized even when the page they are on isn't visible. The rules for which get initialized and which don't are very complicated and depend on a number of things, so it is just best to not rely on the init() method not getting called.
By far the best option for your use-case is to have the proxy portlet listen to the "onRefresh" event, and move the logic from the backing file's init() method into an event-handling method in the backing file, then have this method called when the refresh event is received. Here's a sample portion of the .portlet file for doing this:
<netuix:handlePortalEvent event="onRefresh" eventLabel="onRefreshEvent">
<netuix:invokeBackingFileMethod method="handleRefreshEvent"/>
</netuix:handlePortalEvent>The "onRefresh" event is sent to the portlet only when it is visible on the page, so it should work perfectly for your use-case.
Kevin -
Hi, everyone..
I wonder why we call super.init(config) in init method of servlet... If i dont call it ; when i try to get servletcontext in service method it throws java.lang.NullPointerException...when we call super.init() , what is happening behind the scene? If anybody has a technical explanation for my question , i will be very pleased...
THX FOR YOUR FUTURE REPLIES IN ADVANCE....I am sorry about the uppercases and i dont want to seem smart on java forums... Anyway, m8 this is the thing that i know... i meant; for instance when we override doGet or doPost method ; we dont need to override init method; but the server loads the servlet and we can get the context of the servlet in these methods easily by calling getServletContext() method; however when we want to call service method implicitly by jndi, servlet needs to be loaded and init method must call its parent...(i also write down in web.xml <load-on-startup>.... for that servlet).
thx for your replies in advance.... -
Why do we use init() method instead of constructor to initialize a servlet?
Why do we use init() method instead of constructor to initialize a servlet?
I suspect the reasons are partly historical. A servlet is loaded dynamically, by class name and, once you've loaded the Class, it's easier to to a newInstance, using the default construtor than it is to search for a particular matching constructor and invoke it.
Maybe you are looking for
-
Issues installing 0IC_C03 dataflow in BW 7.0
Hi experts, We are trying to install the dataflow for stocks infocube (0IC_C03) in BW (release 700 level 0015) from Business Content (release 703 level 0008) and we get the following error message when installing the transformation from Infosource 2L
-
What can i do to fix the robotic sound on my macbook pro 10.7.4?
Lately I have been experiencing a problem with my audio. After a short while, if I am using skype or watching a videa on youtube, for example, the audio get fragmented and very robotic. If I disconnect from skype or pause the video, it corrects itsel
-
We have a website that uses Action Script 2 (AS2). We load .mp3 files from our server to our flash program on our website. Sounds built into the flash library load fine, but .mp3's loaded from our server do not. The audio loads a few seconds of the f
-
MacBook (13-inch, Aluminum, Late 2008) 2 GHz Intel Core 2 Duo 4 GB 1067 MHz DDR3 NVIDIA GeForce 9400M 256 MB Mac OS 10.10.2 Safari 8.0.4 While on my cellphone sitting in front of my computer (inactive but on), no keyboard or mouse activity, Safari ju
-
When can I expect the activation email (iPhone dev)?
Hi, Very excited to submit two apps I've been working on in recent weeks for AppStore consideration. I've already registered and made the $99 payment, and am awaiting what I'm assuming is an activation email. Any idea when I should expect to receive