• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Passing redirect from bean class to JSP

 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would like to create a JavaBean (in Tomcat 4.1.3) that can pass the response.sendRedirect() to a JSP where the JSP will actually take that response.sendRedirect() method and redirect the page but cant figure out how to do it in the JavaBean class. The redirect would only happen if a condition was met in my JavaBean class:



JSP called main.jsp

[ July 29, 2007: Message edited by: Nick Davenport ]
 
Sheriff
Posts: 67746
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
Check the API for sendRedirect(). What does it return?
 
Nick Davenport
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally have a redirect from a bean working in the JSP using Java Bean and jsp:useBean tag.

Everything works great and now I was just wondering how I can eliminate the scriptlet part (<% redir.RedirectPage(response); %>) and put it into a useBean tag? I dont have any access to JSTL due to strict environment I work in so I want to get this working with useBean tag if possible.




Bean


[ July 31, 2007: Message edited by: Nick Davenport ]
 
Bear Bibeault
Sheriff
Posts: 67746
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

Originally posted by Nick Davenport:
I dont have any access to JSTL due to strict environment I work in ...



Wait a minute... the powers that be want you to eliminate scriplets from the page, yet will not allow use of the JSTL and EL?

If so, that is the most moronic thing I've heard this year. Please tell me it isn't so!
[ July 31, 2007: Message edited by: Bear Bibeault ]
 
Nick Davenport
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
100% true and it will take about another 6 months or more before I can get it (JSTL) approved with paperwork etc.

Any advise on how I can get this to work now without JSTL because I want a scriptlet free JSP.

Thanks
 
Bear Bibeault
Sheriff
Posts: 67746
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
I can't tell from what you said if your are prohibited from using scriplets, or just don't want to. Which is it?

If the latter, much as I feel that scriplets should be stricken from the memory of every JSP developer, I'd give it up until you can use the JSTL. A JSP without either of scriplets or JSTL can't do very much.

You will be limited to just what you can do with the JSP standard actions. And trying to twist those to do things that they were not intended to do will cause more harm and confusion than scriplets do.
 
Nick Davenport
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for information.


I can't tell from what you said if your are prohibited from using scriplets, or just don't want to. Which is it?



I can use scriplets but want to get into the practice of not using them and it could be a long long time before I get JSTL. I was hoping to get it to work and improve my javabean skills.
 
Bear Bibeault
Sheriff
Posts: 67746
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
But any "practice" you would get would be less than useful since it would not be practice in the real way that scriptless JSP should be written.

You can increase your "bean skills" without resorting to using them in artificial manners.

Here are some suggestions for getting some practice in writing scriptless pages even while still using scriplets:

  • Be sure that all processing is done in the servlet controller.
  • When accessing beans, only call methods that adhere to the propety pattern: for example getXyz() with no parameters.
  • Use scriplets only for things like for-loops and conditionals. Don't perform any processing that you could not do with the JSTL.

  • [ July 31, 2007: Message edited by: Bear Bibeault ]
     
    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
    Are you allowed to write your own custom tags?

    The app I work on was 100% scriptlet free well before JSTL and EL were out.
    A handful of custom tags and some data structures on the back end to go with them made it possible. We're currently in the process of switching it over to JSTL and EL to standardize things.

    For your original issue...
    The decision to redirect or not should be made before the request ever reaches the JSP.
     
    Bear Bibeault
    Sheriff
    Posts: 67746
    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

    Originally posted by Ben Souther:
    Are you allowed to write your own custom tags?



    Not to make light of the OP's situation, but I would actually find it a hoot if custom tags were allowed but the JSTL was not!
     
    Ben Souther
    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
    It wouldn't surprise me.
     
    What a show! What atmosphere! What fun! What a tiny ad!
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic