Win a copy of Head First Android this week in the Android 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Servlet, managedBean and JSF (generate report)

 
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I need help in the following:

I want to generate report that is from iReport using Eclipse, I create the Servlet class, managed Bean and I have my jsp
In side the Servlet class I have this method:



now in the managedBean(MB)  I whant to call the servlet, How i can do that? and how I can use the RequestDispatcher?

I have this method in the MB but is not completed tell now:




RequestDispatcher dispatcher = request.getRequestDispatcher("/GetName"); >>> what I have to put in /GetName place ?


In jsp:


Thank you in advanc.
 
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JSF works best when it's used with HTML forms.

I recommend that you use a servlet to generate the PDF document. Servlets and JSF can communicate easily, since JSF session-scope objects are simply JSF-managed JEE session objects.
 
wadha alketbi
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your replay. I solve it but now how I can print the parameter in the Servlet class to make sure that the parameter come from the user?
 
wadha alketbi
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


In this method "doPost", I want to print the value of the parameter to make sure that every thing is fine, because the report now open for me and it is showing the data but without the parameter, I thing the report in iReport dose not receive any parameter to make any filtration.

Any help or comments!

Thank you in advance.
 
Tim Holloway
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


That will record the value of the end date in the server log.

For example, a URL like this:

http://localhost:8080/myreportservlet?endDate=2016-09-08

Should produce the message

Request Data parameter value was 2016-09-08

And if the parameter was omitted from the request URL, you would see

Request Data parameter value was null

 
wadha alketbi
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thank you for your help, after I printing the parameter I found that the value is null so that is the reason for the empty report. So any one know why the servlet received empty value of the parameter?

Thank you.
 
Tim Holloway
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Request scope is almost entirely useless in JSF, so what you probably need to do is make "endDate" be a session-scope object.
 
wadha alketbi
Ranch Hand
Posts: 66
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Tim Holloway wrote:Request scope is almost entirely useless in JSF, so what you probably need to do is make "endDate" be a session-scope object.



How I can make "endDate" be a session-scope object?
 
Tim Holloway
Saloon Keeper
Posts: 24555
168
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can obtain the HttpSession object via the FacesContext and create/read the date as an independent object. OR you can define a JSF Managed Bean in session scope and make the endDate be one of its properties. Which is probably more useful, since then the endDate can be entered in a JSF form by the user.

JSF session scope is exactly the same as J(2)EE session scope, so your servlet merely needs to retrieve the object whose name matches the JSF managed bean name,
reply
    Bookmark Topic Watch Topic
  • New Topic