Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Dinesh Kumar

Ranch Hand
+ Follow
since Jul 03, 2002
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Dinesh Kumar

IF I have two different application servers that are to be load-balanced (serving one application eventually), how do I maintain sessions?
14 years ago

Originally posted by Dinesh Kumar:
[QB][/QB]



Thanks. This is helpful.
14 years ago
Thanks Adeel.

I also have some simple classes (models) that are carrying out some tasks. I am calling the methods in these classes from the servlets based on certain conditions that I check in the servlets. So if a condition is tru the servlet calls method "a" in the class else it calls method "b" etc.

My only worry was I was ending up with quite a few servlets (about 10) and I thought this may not be correct.

Thanks for clearing this.
17 years ago
I posted this in the design patterns forum a couple of days ago but got no reply. Perhaps put it in the wrong forum?

"I am developing a sample web application using the Model view controller pattern. I have a handlerServlet which I use to pass control to other servlets. Those servlets contain some of my business logic and in turn pass control to JSPs for display. Like depicted below

handlerServLet --> Task specific servlets --> JSPs (results / user inputs)

Now, based on certain user inputs I need to forward the user from the JSPs to some other servlets. I reckon this is going to get me into a bit of a mess.

Is it alright that I pass the control back to the handlerServlet and then go to the respective servlet from there? On the other hand, isn't it a bit of an extra overhead when the control can go direct from the JSP to another servlet?

This is the dilemma I am facing. Can someone advise?

Also should I make a servlet for each business logic task that I want to perform? Or should I just have a new method in my handlerServlet?

Thanks. "

Can someone pls also explain whether MVC requires that you have a single controller servlet. What if it becomes too unweildy? Can we have multiple controller servlets co-ordinating?

Thanks again.
17 years ago
I am developing a sample web application using the Model view controller pattern. I have a handlerServlet which I use to pass control to other servlets. Those servlets contain some of my business logic and in turn pass control to JSPs for display. Like depicted below

handlerServLet --> Task specific servlets --> JSPs (results / user inputs)

Now, based on certain user inputs I need to forward the user from the JSPs to some other servlets. I reckon this is going to get me into a bit of a mess.

Is it alright that I pass the control back to the handlerServlet and then go to the respective servlet from there? On the other hand, isn't it a bit of an extra overhead when the control can go direct from the JSP to another servlet?

This is the dilemma I am facing. Can someone advise?

Also should I make a servlet for each business logic task that I want to perform? Or should I just have a new method in my handlerServlet?

Thanks.
Rei,

Can yiu give some more detail. Is the "hostname" localhost or some other? Which port are you connecting to? It'd be easier for someone to reply in this case if you could attach the server class and the client class code.

I think the "handler" that you're talking about should be the rmiregistry that is listening on the host ort.

- Dinesh
17 years ago
I am running the Sun's RMI introductory bundle of programs on my machine.
Essentially -
1. Defined a server class with a remotable method sayHello(). This method is in a class that implements the Remote interface.
2. Started the orbd
3. Created the skeleton and the stub through rmic
4. Called the sayHello() from a client.
All the code is exactly the same as on Sun's tutorial. when I run the client it displays the message "Client: Obtained a ref. to Hello server" after the lookup.
But the call to sayHello() on the next line in the client program displays the "Hello from Mars!" message on the server window rather than on the client window.
Is that what is supposed to happen or I am doing something silly.
Thanks in advance.
18 years ago
Dear Mr. Neal,
Is JUnit the only one of its kind available for simple and effective unit testing of Java code? Does your book mention the names of some of them? (if not details).
Does your book describe it in more detail than I am able to lay my hands on through searching the web?
Thanks,
Dinesh
18 years ago
Svetlana,
Something different you maight want to look at...
Make a multidimensional (n dimensions) array of all the locations. e.g. the top-most dimension could consist of all the top level containers (rooms, labs etc.)...then in the next dimension keep all the next level containers (closets, refrigerators, racks etc.). In the next level keep the next lower level e.g. top-drawer, top-shelf in the rack etc. Keep as may levels as see ok for the purpose now. You can add another top-level or bottom-level to the array later.
So a particular item in your inventory would be stored at say location(2,3,1,5) where the first top level (2) has the room, the next level (3) has the closet identification, the next level (1) has the drawer id within the closet and the last level (5) may be has the bottle id (assuming the top drawer has a number of bottle of different chemicals).
Then you can have a sorted linked list for each member. This list would contain all the locations that this member has access to. e.g. loc(2,3,1,5), loc(2,2,3,4).....etc. You can sort this list for each member in descending order of the number of accessible locations in a room. For example, if a person has most of her items in room 3, closet 2 then the locations in room 3, closet 2 can be near the beginning in the linked list for this person so that a search would be shorter.
HTH.
Dinesh
[ February 10, 2004: Message edited by: Dinesh Kumar ]
18 years ago
I feel the decision about simplicity is a personal one. For simple applications one can easily use a combination of JSP/HTML and servlets. It does not get any more complex than ASP and at the same time one has the feeling of comfort that should one need to scale it up, J2EE technology will not run out of solutions.
Personally I feel more comfortable programming in JSP maybe because I learnt it before I learnt ASP and have been using it longer.
...Dinesh
18 years ago
I think code review can never be completely automated for all that it seeks to achieve, namely,
1. That there are no obvious bugs in logic
2. That there could perhaps be a better way of doing it
3. That it is simple and self-documentary enough for someone else to be able to change it
and lastly, that it makes all the reasonable assumptions and premises about the nature of the problem and all its "unknowns".
Frankly, any code review would be conducted (and structured) keeping in view how many of the above mentioned goals do you seek the review to achieve.
I work for a CMM level 5 company. That does not really mean that if I have to sneeze I have to open a manual to see the standard way of doing so.
The CMM levels go from a state where the process you follow is standard enough (broadly) to be repeatable across projects. Then you go to the next level of "managed" etc. till you reach the final stage where you are not stagnant with one set of rules and processes and are indeed constantly looking to improve (optimize) them.
Yes, it's true that not every nook-and-corner of your work can have a rule-book to tell you how to do that job. What it means is most of the work that you do follows a pattern (and the same pattern followed by others) and the pattern itself is subject to concious improvement.
Though it's true to some degree that you can fake some of the things in front of an auditor but the chances are that you'll be caught for the CMM auditors don't rely on record checking (which can be made up) but on extensive interviews and cross-interviews with different sections of the organization. Sometimes as many as 40 to 50 persons can be interviewed individually as well as collectively over a period of 7 days or so. Coupled with selective record checking, this makes it a reasonably tight way of judging what is the strength of the processes of an organization.
You can't really doctor 50 random persons to give a consistent set of replies to the interviewer for every conceivable question unless you have been following the processes in spirit.
Also, an earlier post saying that for level 3 you have to show one project that followed level 3 processes is probably inaccurate in my view.
Suresh,
To give a more elaborate reply, the HttpServletResponse res object that is being passed as a parameter actually is an object of a class that implements the HttpServletResponse interface.
You'll find that most of the time it's the interface that you're using during your Servlet programming. This is because the Servlet specs. doesn't manadate any class names for most of the interfaces. That's left upto the Servlet containers (e.g. tomcat) to design.
So if you try something like, System.out.println(res.getClass()) on your response object, you'll find the class name that the container is actually using.
Since this class implements the interface HttpServletResponse, it is perfectly legal to declare your res object to be of the type HttpServletResponse.
Same is the case with many other interfaces in the Servlet API.
Hope that helps.
18 years ago
Thanks a ton, Frank.
18 years ago
Hi,
I have a welcome.jsp page. I am also keeping track of users logged in. Once a user logs in, I update an attribute in ServletContext. Besides, his user deials, I also store a reference to his request and response objects in the ServletContext.
Whenever a new user logs in he is shown the welcome page. But I also want to notify all the other users that are logged in and show them a specific page telling them about the user who just logged in. I am trying to do it through ServletContextAttributeListener.
But when I fetch the request objects stored (for users already logged) from the ServletContext and try to send them a message about the new user, by saying (requestObject.getRequestDispatcher("/notifyOtherUsers")).include(requestObject, responseObject), I do not get any result.
There is no exception thrown either and the Servlet does not execute beyond this line. If I comment out the line, the servlet executes further without problems.
Can I use the previously stored request objects this way to obtain a RequestDispatcher and then to include a page to those response objects?
Can the other logged in users be notified this way or they have to click on a "refresh" link somewhere to see who is the latest user that logged in!
Thanks in advance.
18 years ago