• Post Reply Bookmark Topic Watch Topic
  • New Topic

a little Bean Prob  RSS feed

 
Baka Neko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Howdy
Ok..here it goes my little Prob:
Im currently working on uploading a File via Smartupload. Upload is working as a Servlet. But i also wanna store the Filenames / Extensions and an ID to a MySQL Database. Therefore i need these Strings to store em.
Im getting these Strings in my UploadServlet and Im sending em to my Files-Bean.
Code of the Bean:
package dasProjekt;
public class DieFiles {

private String ID;
private String Filename;
private String Extension;


public DieFiles(){
}

public String getID(){

System.out.println("in getID");

return ID;
}
public void setID(String ID){
System.out.println("in setID");

this.ID = ID;
}
public String getFilename(){
System.out.println("in getFilename");

return Filename;
}
public void setFilename(String Filename){

System.out.println("in setFilenam");

this.Filename = Filename;
}
public String getExtension(){
System.out.println("in getExtension");

return Extension;
}
public void setExtension(String Extension){

System.out.println("in setExtension");
this.Extension = Extension;
}
}
Nothing special. Ive tested the Bean with the System.out.println(...) and everything is ok with my Bean.
BUT If I wanna see the Filename, ID, Extension in my JSP via by calling the method itself <%= DieFiles.getFilename()%>
Im getting:
NULL
And if Im trying <jsp:getProperty ...> Im getting:
org.apache.jasper.JasperException: Cannot find any information on property 'Filename' in a bean of type 'dasProjekt.DieFiles'

But like Ive said, if Im doing a System.out.Println(einFile.getFilename());
in the Servlet its working fine.
Heres the code from my JSP:
<%@ page language="java" %>
<jsp:useBean id="einFile" class="dasProjekt.DieFiles" scope="session"/>
</jsp:useBean>
<HTML>
<BODY BGCOLOR="white">
Upload komplett!
Hier muss halt auch ne DB Connection entstehen in der die TaskID, Filename zur DB geuppt werden.
Alles l�uft �ber meine DieConnection Bean ab!

Filename: <%= einFile.getFilename()%>
Filename: <jsp:getProperty name="einFile" property="Filename"/>
<meta http-equiv="refresh" content="5; url='UploadedFiles.jsp'">

</BODY>
</HTML>

Any help and suggestions would be awesome
TIA
Baka out
 
Detlev Beutner
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Baka,
at a first glance, it seems to me that there must be something wrong with the bean in the session (that means, the bean you have filled before just is not in the session). With this, the <jsp:useBean> tag constructs a new bean, sure with an empty "Filename" (means not "empty" but null).
This is why the null is returned.
The JasperException I do not know, but there for sure is some problem with your bean definition - "Nothing special." is not quite true: A bean member starts with a lower case letter, so it must read "id" instead of "ID", "filename" instead of "Filename" and "extension" instead of "Extension". This at least differs from bean syntax.
With this together, all should work right, even if you still have the job to determine why there is no bean in your session when you expect it to be there.
Hope it helps
Detlev
 
Baka Neko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thx for your Reply
Ive lowercased all the Strings in my Bean..and if Im doing <jsp:getProperty..> now Im also getting Null and no Jasper Error anymore.
Soo..I guess its like you�ve already said..there is no filled bean inside my session....
Have to get this bean into my session and have to read a little more about Beans
Baka out
 
Baka Neko
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ahaahaha Ive solved it...jeez.stupid me.
HttpSession mysession = request.getSession(true);
mysession.setAttribute("einFile", dasFile);
Inserted this into my Servlet..and now its working like a charm
Many thx for helping out.
Baka out
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!