Rajesh Ronald Reagan

Greenhorn
+ Follow
since May 28, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Rajesh Ronald Reagan

Hi Nihar,

Servlet's destroy() method is to basically to unload the servlet.

Primarily this is used for GC.

And during this time you cannot initialize any rather than closing it.

Good practice of Servlets is to not call the destroy() method explicitly.

May be you could do like the following.




Regards,
Ronald
11 years ago
Rashmi,

The answer to your query is , in your bean class.

While deploying in tomcat,

Please make the following folder structure.

$Tomcat_Root\webapps
+<all jsp files>
+<WEB-INF>
-------- +classes
---------- +Bean
------------- +MyBean.class
-------- +Servlets
------ +web.xml
+<META-INF>

As Devaka Cooray rightly pointed, please do not move the source to your webapps directory.

Regards,
Ronald
11 years ago
Hi Rao,

For the entire web application, there will be only one ServletContext.

ServletContext is created when a new deployment is made after that this ServletContext will be used by all the jsp's and servlet's in the web application.


The NPE is thrown because , the ServletContextListener is not initialized.

You should instruct the container.

Kindly check whether you had your entry in the deployment descriptor ?

If not please add the below code.




Problem is the listener is not initialized.

If you have any queries you can checkout the following link.

http://www.javatips.net/blog/2011/12/servletcontextlistener-example

Dont forget to report back

Regards,
Ronald
11 years ago
Hi Sangita,

In HTTP World the session on the same browser is very normal

I.e Two different users when accessing the same application only one user session is allowed from the same browser. Ex Gmail. Please try to signin in the same browser with multiple user. This is a bad implemenation quite I can tell.,

Since http protocol is a stateless protocol (as it is not persistent), whenever browser sends request then it is always interpreted as a new request. When the first request goes to the server, a session object is created .To maintain the session, server creates a token .The token is transmitted to the client by the response object and gets stored on the client machine. URL rewriting can also be used where the cookies are disabled by the user.

The best way to overcome this is to rewrite the URL, which will append the session id to the url.

use the response object to get the method encodeURL to append the sessionid.

http://www.roseindia.net/tutorial/java/jsp/URLrewriting.html

A good example is given above.

Regards,
Ronald


11 years ago
Hello Bhaskar,

I believe you have set the response object's content type to the following.



It means the response object writes this data to ms-excel format.

Serlvet API can only set the content type to microsoft excel format. There is no API for creating for multiple workbook.

If you have verified the generated xls file, you could have noticed only one worksheet possibly without the grey lines. Servlet API supports only the content type to microsoft excel, but not the Excel creation API.

If you have table data or results put it into an arraylist , initialize the jxl write class to write it to multiple worksheet.

Till now Oracle Corp, has not found Servlet API to create excel worksheets.

Regards,
Ronald Reagan Jr
11 years ago
Hi Rashmi,

Be specific, are you talking about application specific beans ? the one with getter and setter methods ?

Since it is like the Java Class, you can keep it in your package.

Please take a look below.

i have a package called com.xx.yy.beans. i have so many beans in it. I require the following four beans in one servlet.

Step 1 Import the package in the servlet.


Step 2. In servlet where you initialize this, either in the init() method ?

For Example the following is a bean code.



I need this to be in my servlet. Say a HttpServlet.

This is how i access the Bean.



I hope this would make you understand much better.

I believe you are trying in eclipse. A suggestion, Do not create servlet class in eclipse using the template that is the wizard. Create a general class and add the methods one by one.

Regards,
Ronald Reagan Jr.
11 years ago
Hi All,

Good day, am struck with a basic error, which the designed application isnt moving ahead.

The servlet which is configured for initializing the backend process throws NPE.

Following is the code of the servlet.



And the web.xml



i gave value 2 since am loading 2 more servlets freemarker and log4j servlet.

I tried in multiple ways but no use.

This is the error log.




Any help would be appreciated.

Regards,
Ronald Reagan Jr.
11 years ago