Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

doubt on redirect

 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Say i have a jsp file called "a.jsp"

a.jsp --- says it has lots of code but at the last line i do a static include (@include) and include "b.jsp".


"b.jsp" -- has nothing but simple one line of code which says "response.sendRedirect("c.jsp");


I want to know the output when the user goes to "a.jsp"?

Q1)Will the user be taken to "c.jsp" page?
Q2)What if some exception occurs in "a.jsp" before includeing(using @include) "b.jsp" itself?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maan Suraj wrote:
a.jsp --- says it has lots of code but at the last line i do a static include (@include) and include "b.jsp".

It's 2011. Why is there Java code in your JSP? That's a bad practice that has been discredited for over 9 years now. Don't you think it's time to update your JSP knowledge with JSTL and the EL?

Or, if the only purpose of this JSP is to contain code and not to render any view, it should not be a JSP at all, but a servlet.

I want to know the output when the user goes to "a.jsp"?

Seems easy enough to test on your own. What happens when you try it?
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When questions are asked..it's asked for a purpose....

It's 2011. Why is there Java code in your JSP?


Its no information to me....

That's a bad practice that has been discredited for over 9 years now. Don't you think it's time to update your JSP knowledge with JSTL and the EL?

Seriously , i did not had the choice to ask the same, since it was asked in my interview.If i had the luxury, i would have asked her the same.


Seems easy enough to test on your own. What happens when you try it?


I believe it goes to "c.jsp"..but then as i said "believe" because am not sure...Why am not trying it..because i dont have my softwares installed currently and i can't do it either right now ..now dont ask me why....


So thought of asking people here....

So as i said in begining of my post :"When questions are asked..it is asked for a purpose.." and not out of fun ...





 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To be honest: there isn't enough information to know what will happen. It depends on what the JSP is doing; if it's emitted enough output to cause a flush, you'll get an exception. Otherwise, the redirect could occur.

Its no information to me....

Then you've got some catching up to do. If you are interviewing for a job working with JSPs, what if your next question is "What is the best-practice way to write JSPs without scriptlets?"
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends on what the JSP is doing; if it's emitted enough output to cause a flush, you'll get an exception. Otherwise, the redirect could occur.


Ya this is a good point....


Then you've got some catching up to do. If you are interviewing for a job working with JSPs, what if your next question is "What is the best-practice way to write JSPs without scriptlets?"


I got your point...Even we are not using scriptlets in JSP in our project.

It's just one odd question asked and interviewer did not wanted any servlets and all.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65535
108
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sometimes interviewers ask the weirdest questions (or reveal a lot about their level of competency).
 
Maan Suraj
Ranch Hand
Posts: 299
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sometimes interviewers ask the weirdest questions (or reveal a lot about their level of competency).

Hmm...very true
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!