Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Response various from struts page and jsp page

 
Yog Ananth
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two web pages one is a jsp page and another one is struts page how i differentiate in servlet whether the response is from jsp or the response is from struts. Please clear my doubts.
 
Eugene Lucash
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most novices misunderstand the flow of web applications.
When response is sended back to browser, browser do not have
any special knowledge who generated request (servlet, jsp, struts(manual?,jsp?,velocity?)).
But you can pass this information by yourself. For example, generate hidden
field in response form, so your next submit processing can investigate this parameter.

--> Render response
Servlet -->
out.print("<input type='hidden' name='generator' value='servlet'/>");
Jsp -->
<%= ssdsd %><input type='hidden' name='generator' value='jsp'/>

--> Submit
-->
String gen = request.getParameter("generator");
if (gen != null && gen.equals("jsp")) {
...
} else {
......
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic