• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing a Variable declared in a Servlet from a bean

 
Steve Dyke
Ranch Hand
Posts: 1619
1
  • Mark post as helpful
  • send pies
  • 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);
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
Author and ninkuma
Marshal
Pie
Posts: 64830
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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: 1619
1
  • Mark post as helpful
  • send pies
  • 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:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic