• 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
  • Paul Clapham
  • Ron McLeod
  • paul wheaton
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • Mikalai Zaikin
  • Himai Minh

?How to share JavaBean information with a Java HttpServlet?

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

I had some code that worked a long while back, but it is not failing. It sucessfully shared a javabean object between a jsp and a servlet. As memory serves me, the JSP created a bean and set a property, e.g.



In the servlet I had code that included this:



I could then cast the object to an 'Info' object (bean) and get or set properties.

I can no longer get this to work.

Can some one recommend a way or point me to a document that explains this.

Thanks. I have already spend a lot of time researching this without success, so
your help is appreciated.

Jim A.
 
Saloon Keeper
Posts: 6932
164
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "I can no longer get this to work' mean? What, exactly, are you trying to do, and what, exactly, is the result? Post the relevant code excerpts.
 
Jim J Anderson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

What does "I can no longer get this to work' mean?



I have a website in development. When it was working, I could:

1) bring up the main page
2) fill out a form
3) submit the form
4) pass the form data as a URI to the java HTTPservlet
   [NOTE in this step, a javabean object handle was passed as part
     of an HttpServletRequest object from
      the JSP page to the servlet]
5)  process the URI
6) based on the URI data from the form, the servlet will then
     bring up the appropriate response page

The current behavior is identical until step 4. In step 4 the
    HttpServletRequest object does not have a handle to the
    javabean object, but a 'null' handle. Consequently, the
    servlet fails and passes a null URL to the Tomcat server
    and the server displays a blank screen.

Regarding code, this site is proprietary and I send the source code 'as is'.
I will create a cleansed version and submit it.
 
Marshal
Posts: 26537
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I remember code like that. But I never actually put any of it into production because JSTL and EL had taken over. This was 15 years ago mind you.

However if that code used to create session attributes correctly and now it isn't, then probably something is different in the new environment and your sessions aren't being maintained in the same way.
 
Saloon Keeper
Posts: 23544
161
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
Actually, it's more common to set create/set a javabean in an HTTPServlet and then have a display (View) JSP reference it, not the other way around.

And proper Java coding standards would name the bean "info", not "Info". Which MIGHT be a problem with some newer resources, but I wouldn't expect that to be the case here.

That's about all I can say based on the limited information available.
 
Jim J Anderson
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

First, I thank you all for the comments. My background is largely C/C++ and java application programming, not in website development. JSP is really relatively new to me and I can say I have a lot to learn. I have read several books about JSP, but as yet, I have not really gotten the correct flow and communication down right. In fact, flow is part of my problem - in application programming there are general logical flows that get followed while in website development the asynchronous client/server communication does not really lend itself to that type of thinking. I'm still working a getting a GOOD client/server model, before I burn it into my brain.

Second, the good news is that I resolved the problem by going back to an old working development website that I have and doing some comparisons. I probably made about 5 changes in the code and that fixed the problem. Thus, I will be closing this thread as resolved.
 
Sheriff
Posts: 67530
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

Jim J Anderson wrote:I have not really gotten the correct flow and communication down right



Please read this article.
 
Jim J Anderson
Ranch Hand
Posts: 51
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bear

Wow! That was quite an article!  Thank you for the pointer.

It is an excellent article to direct me to and I have bookmarked it so I can go back it as needed. I'm not sure I really need to read it again, because I got the underlying message. I have the link, just in case.

I know it will not fix all my problems, but my current 'Model 2' is setup for disaster.

I need some time to restructure my 'sample' websites. Hopefully I can then put together a simple website that works as I expect.

Did I say thank you? Thank you, Thank you, Thank you!

Jim
 
Bear Bibeault
Sheriff
Posts: 67530
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
You are most welcome.
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic