parampreet sethi

+ Follow
since Aug 03, 2009
parampreet likes ...
Tomcat Server Java Linux
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by parampreet sethi

I have faced a similar problem when my eclipse was using jdk 6 and compiling the code in jdk 6. How ever my tomcat was using java 1.5. And at runtime I was getting "Bad version number in .class file" error.
11 years ago
The another way to do it is, store the information in a cookie on client side and grab the value from the cookie whenever it should be shown on frontend.

You can check if the cookie is not present or value is null, grab the value from the database and store it in the cookie.
11 years ago
I agree with Amit. I have used Java JSON API for generating response for DMOZ API ( and it works great and very easy to use.
11 years ago
just a quick question here,

Since notepad uses a window and does not use std out or std err, it does not hit this problem.

Does it mean that any program which uses a window (basically window application) can be run on client side through servlet?
11 years ago
If the logout is done using form submit on the front end, then it should take care of back button click. (Clicking on back button of browser will ask user to resend the information.)

The other thing that you can do is, on all the application pages, you can check for session variables and if they are invalid redirect user to login page.

Ideally when user will click back button, he/she should be taken to login page instead of logout.
12 years ago
You can try putting return after each forward and response.sendredirect method calls.

The forward and sendredirect method calls does not mean that the rest of the code will be ignored. Yesterday I was having the same issue and putting return after each sendRedirect and forward fixed this issue.

Hope it helps.
12 years ago
Thanks everyone. I got the issue.

In my Comparator I have combined the condition for > and = to return 1.

I changed it to separate conditions and returned 0 when the two objects are equal.

Suggestions on implementing this problem in a better way are welcome.
12 years ago
Hi all,

Here goes the problem:

I have categories and multiple sub-categories inside each category.

Each category has a priority assigned to it. Thus the subcategories belonging to different categories should be sorted first in priority and if inside the same category they should be alphabetically sorted.

For Category priority sorting, I created a custom Comparator. I used TreeMap<String, TreeSet<String>> as data structure and passed the comparator while creating the object.

My first level priority sorting is working fine.

I have two issues:
1. The alphabetical ordering within a category is not working. This is because of issue #2.
2. When I try to do map.get(key), it always returns me null.

Is there any basic java concept that I am overlooking while coding this? Or other suggestions how this problem can be solved in a better/faster way.
12 years ago
Looking at the exception, it appears that the jar which contains oracle.xml.parser.v2.XMLDocument class is not in the classpath.
12 years ago
There are two ways to do that.

Using RequestDispatcher as mentioned in above post.
1. This will internally forward your request to jsp/servlet
2. user will get 301 response code
3. the url of the browser will not change.
4. The request object from original browser request will be forwarded to the called jsp/servlet.

Using response.sendRedirect method. (Its part of HttpServletResponse)
1. The request will go back to browser.
2. Browser will have the new url.
3. New request object will be created and sent to the called jsp/servlet. (This means older request object values will not be retained.)

Depending upon the situation one of the above two ways can be used.

12 years ago
You can try using multiple tomcats with load balancing approach. The load balancing can be done using storing images based on some algorithm into different tomcat servers. And then use Apache server at front (using workers module) which will connect to multiple tomcat servers (e.g. using mod_proxy ) based on URL regex.

If possible, you can host the banner images (If they are not coming from a backend source) in Apache server. Its faster and ideal for hosting static content.
12 years ago
I think the better way would be to use a URL Rewrite handler, there you can mention a Regex or the specific URLs From and To.

If you are using Apache in front of your Tomcat server, You can achieve this either by having mod_rewrite module configured for you or if the number of URLs are much lesser then you can use mod_proxy module to forward the URLs to correct address.

You can checkout this for more information on how to set up mod_rewrite module for your Apache server.
12 years ago
You can use application level variables as well. We have three levels of variables depending upon their scope in any web application.

1. Page level - specific to that page or request
2. Session level - specific to a session
3. Application level - specific to the application

To store variables at application level, below mentioned is the sample code:

The other way would be to use the below mentioned code:

In the JSP, you should have

In the servlet, you would have the following equivalent code:

12 years ago
Where have you copied the file? Normally it's available inside webapps/App/WEB-INF/classes folder.

The another thing you can try is removing the full path from

and keep it as

This should by default create the log file inside the Tomcat logs folder.
12 years ago

One way could be to call BServlet from AServlet by passing on the request and response,

This way the control will be transferred to BServlet's doGet method, there you can get the values from requests and call the method which is required to be called and then in the end call the jsp where you want the response to come as output.

The other benefit of using disp.forward method is that it will transfer the control internally and user will not be aware of the request being processed by BServlet.

I am not sure this will help you or not, but this is just another way of solving this issue.
12 years ago