• 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
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Accessing a Variable declared in a Servlet from a bean

 
Ranch Hand
Posts: 2278
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I declare a variable in a servlet:

public static String drawingString2.

Then I have:

Drawing drawingString = Drawing.getDrawing(rdrawingnumber.drawingNumber);
String drawingString2 = drawingString.getDwgName()

Why do I get the empty or null value in my java class with this:

String fileDrawingString = DrawingInquiryServlet.drawingString2;
System.out.println(fileDrawingString);
 
Sheriff
Posts: 67754
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
Please take the time to choose the correct forum for your posts. This forum is for questions on JSP.

This post has been moved to a more appropriate forum.
[ May 31, 2007: Message edited by: Bear Bibeault ]
 
Bear Bibeault
Sheriff
Posts: 67754
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 was initially going to move this to the Java Beginner forum as learning how to use static variables is not a servlet issue... BUT...

Using static variables to share information in a multi-threaded environment such as a web application is a total recipe for disaster. Don't do it!

Please explain what you are trying to share, and what you want to share it with, and in what scope the sharing should take place so alternatives that will work can be suggested.
[ May 31, 2007: Message edited by: Bear Bibeault ]
 
Steve Dyke
Ranch Hand
Posts: 2278
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Basically I need to upload a file and have the app give the file a name based on the drawing number the user is working on at the time.

My bean code which works great bu I want to programatically control the path/name of the file output:



My calling code is in a JSF page:

 
reply
    Bookmark Topic Watch Topic
  • New Topic