• Post Reply Bookmark Topic Watch Topic
  • New Topic

some interesting question on Redirecting

 
sirisha makkapati
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when we are redirecting our servlet to some other servlet which design pattern we can use how it will helpful?

I Am thinking this one is Adopter Design pattern is it right?

Any one please tell me right answer and explain how it will be helpful.
 
Mohits seth
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi..
I dont think any design pattern is there that will match this requirement.
Design patterns are targeted to solve application specific problmes.
(E.g MVC,Transfer Objects,Intercepting filters etc)
It doesent cares about are you using re-direct or forward.
its goal is to give proper design to suit your problem.
 
rajesh ssh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
adapter design pattern is used to implement some interfaces so that we can use this adapter class as base instead of implementing..,
 
rajesh ssh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in the case of redirecting i thought you can use pattern ,think suppose the code is like this..will it work

redirectDesignPat(HttpServletResponse , url);//calling pattern method is in one particular class which is a servlet

the below code is in particular servlet which is resusable for redirecting..
redirectDesignPat(HttpServletResponse res ,String url)
{
res.sendRedirect(url);
}

but still there is problem with above code has to be in servlet it shouldnot be a normal java class.,
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohits seth is right on the mark. Redirecting is a method call, there just isn't a pattern that applies to it. Don't try to find a pattern for everything, there are too many already.
 
rajesh ssh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
friend the pattern i have used is not new one...when you think about service locator..then you can get this...
patterns we can use to solve our problem...whether it is new or old our criteria is to solve the problem...
 
rajesh ssh
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi frnds...after discussing with my frnd i came to know about my mistake..that is the code which i have given is wrong way of doing..may be as Ulf Dittmer said we maynt use design pattern for redirecting...or including...
the mistake of my code is
on that one i have used one servlet , that servlet i have used as resusable servlet but
calling that servlet is by creating object which is not a good way...so this is the wrong..
finally...the code is i have given is wrong ...sorry...
thank you
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Smart boy",
Welcome to the JavaRanch.

We're a friendly group, but we do require members to have valid display names.

Display names must be two words: your first name, a space, then your last name. Fictitious names are not allowed.

Please edit your profile and correct your display name since accounts with invalid display names get deleted, often without warning

thanks,
Dave
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65522
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"smart boy",

rajesh malla was a perfectly valid display name. Why did you change it?

Be aware that accounts with invalid display names are disabled.

bear
JavaRanch Sheriff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!