aspose file tools*
The moose likes Servlets and the fly likes Accessing a Variable declared in a Servlet from a bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Accessing a Variable declared in a Servlet from a bean" Watch "Accessing a Variable declared in a Servlet from a bean" New topic
Author

Accessing a Variable declared in a Servlet from a bean

Steve Dyke
Ranch Hand

Joined: Nov 16, 2004
Posts: 1490
    
    1
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);
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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 ]

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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

Joined: Nov 16, 2004
Posts: 1490
    
    1
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:

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing a Variable declared in a Servlet from a bean