Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with jsp forward

 
nick angel
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to everyone. The problem is as follows. I have a form that needs to be submitted which has the following form:



The jsp CompleteRequest.jsp does some processing to the parameters(formatting) and logs a cookie.
Then depending on the value userType received, I wish to redirect to another page.
I know that using a servlet for processing would be the ideal choice, but we were asked to use a jsp as an
intermediate for the small amount of formatting.
In the CompleteRequest.jsp I had written the following:



This however does not seem to work. I did a little checking and figured out that I cannot use absolute paths.
Also I was just wondering if it is possible to not leave any trace of html code in case the process gets held up in the intermediate page for some reason.

I was just wondering if anyone could point me in the right direction. Any help or advice would be greatly appreciated.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65105
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by nick angel:
I know that using a servlet for processing would be the ideal choice, but we were asked to use a jsp as an intermediate for the small amount of formatting.


This makes no sense to me. Your instincts are correct -- why were youu asked to use a JSP to do a servlet's job?

In any case, you cannot forward to a resource on another server. You'll need to do a redirect.
[ March 02, 2007: Message edited by: Bear Bibeault ]
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would rather do a send redirect from a servlet, like Bear suggested. That JSP is just sitting there with some controller logic and it was supposed to be the view. What is worse is that the user will never see any useful content on this page. He will simply be redirected to some other page, which means your view has completely been transformed to a controller. Use a servlet instead
 
nick angel
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you both for your prompt response. I am glad my instincts were right.
I a still a student and I don not pretend to know all. However some of our teaching assistants
in my humble opinion, have learned a language but not how to actually use the tools they have learned.
While other T.A s are great some leave a lot to be desired, as is this particular case.
Again thank you for your time and help.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic