Making a Variable value in a Servlet visable to a bean
If I declare a variable in my servlet:
public static String drawingString2;
Then also in my servlet I have:
Drawing drawingString = Drawing.getDrawing(rdrawingnumber.drawingNumber);
String drawingString2 = drawingString.getDwgName().toString();
Now in my bean I have:
String fileDrawingString = DrawingInquiryServlet.drawingString2;
System.out.println(fileDrawingString);
The console displays either a null or empty value depending if I have the .toString() added or not.
Note: the servlet will output a valid drawing number to the console.
If there is a better way to get a value computed in my servlet to be visible in my bean please let me know.
[715 byte] By [
SLDykea] at [2007-11-27 6:04:51]

Don't do that! You don't want to depend upon data kept in members of a servlet class, whether they're static or instance fields. That can break the thread-safety of the servlet. Remember, one instance of your servlet services all the requests
What bean is this? Where does it come from? Where is it used? Can't you just have a setter method on the bean for the variable? If the bean needs the variable in order to do it's work, could the variable be passed in to the bean's constructor?
This is my bean in which I want to dynamically assign the file path/name:
package com.drawingpdmw1;
import java.io.*;
/**
* @author sde
*/
public class filePush {
private byte[] fileString;
public filePush() {
}
public void setFileString(byte[] bytes) {
this.fileString = bytes;
try{
File ecnString = new File("C:\\sdetest.rtf");
boolean success = ecnString.createNewFile();
FileOutputStream fos = new FileOutputStream(ecnString);
fos.write(bytes);
fos.close();
System.out.println("NoError");
}
catch(IOException ioe){
System.out.println("Error");
}
}
}
I am calling this from a JSF fileUpload control using WebSphere:
<c:if test="${pendingOther}">
<c:if test="${writerQue}">
<hx:fileupload styleClass="fileupload" id="fileupload1" value="#{fileBean.fileString}">
<hx:fileProp name="fileName" />
<hx:fileProp name="contentType" />
</hx:fileupload>
</c:if>
</c:if>
The file path/name is dictated by the drawing number that the user is in the process of working on at the time.
I thank you for the help.