Win a copy of Functional Design and Architecture this week in the Functional programming forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

jsp/servlet design problem

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please bear with me, I am still pretty new to Java. I am trying to create a web report with JSP and Servlets under Tomcat5. This reports has several independent pieces, so I would like to make the report modular, with a servlet for each piece to perform the necessary data access and logic.

I was hoping to design it in the following way: Each servlet would perform it's logic, write the results to a bean, and then forward to a JSP Fragment (.jspf). Then I would have a main JSP page that would just include each servlet that I needed (hence getting the output from the JSP Fragments). That way I could add or remove each piece with ease from the JSP.

I have begun to realize, however, that this doesn't work. Because of the nature of JSPs & Servlets, the jspf that the servlet forwards to doesn't get parsed. Instead, it's code is written to the browser where it is included. I obviously need to change the way I'm doing things, but I am not sure how. How do I keep this modular? Thanks.
 
Sheriff
Posts: 67590
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why are you naming the JSPs that you are forwarding to as fragment files? That should be reserved for files inlcuded using a static include directive.

Your issue may be as simple as renaming the files to .jsp.
 
Daren Reavis
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!!! You were right. All I needed was to do was make the jspf a jsp, and it started working. Thanks again!
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Daren Reavis:

... Because of the nature of JSPs & Servlets, the jspf that the servlet forwards to doesn't get parsed. Instead, it's code is written to the browser where it is included.



This is not correct.
If your JSP code is ever sent to the browser something is wrong.
As Bear mentioned, and you have probably noticed, jspf files are parsed on the server; but only when they are statically included.

When you get a chance, read this entry in our JspFaq. It covers the difference between the two include mechanisms in JSP.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic