aspose file tools*
The moose likes JSP and the fly likes error occuring while use jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "error occuring while use jsp" Watch "error occuring while use jsp" New topic
Author

error occuring while use jsp

A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114


this is the error i am getting while accesing the view.jsp.

here below is my view.jsp and mybean.java codes.

view.jsp


mybean.java


please clarrify my error.


Thanks,
www.Admakr.in
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Where did you place the bean's class file (what directory)?

By the way, the Java naming convention states that class names should start with an upper case letter "MyBean" and object variables pointing to an instance of that class start with a lower case letter "myBean".
Not following that convention makes your code difficult and cumbersome for others to read.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Abhinit Saxena
Greenhorn

Joined: Jan 10, 2006
Posts: 18
best practice to use a bean in tomcat
-------------------------------------

Step1) put your java file in classes folder
step 2) compile it with javac in following manner

javac [-classpath .;<other classpaths>] <filename>.java -d .


-d . will create all folders properly in your classes folder as specified in package.

Hope it will help you out
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61066
    
  66

Originally posted by Abhinit Saxena:
best practice to use a bean in tomcat

Step1) put your java file in classes folder


This is not something that I'd consider doing or consider a best practice. Only class files need be placed in the WEB-INF/classes hierarchy.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
value="<jsp:getProperty name="mybean" property="firstname"/>"/>


You can't assign a value using <jsp:getProperty> you can merely display it

to achive the above thing use EL or otherwise write simple Scriptlet

or (if JSP 2.0 is supproted by your server)

I hope this helps

Do focus on suggestions given earlier related to code conventions

Shrinivas
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi,
first i have to say thanks for all of ranchers.

i did your suggetions now also same problem .

i changed the class Mybean and value=<%=mybean.getFirstname()%>;

still it is giving the problem as "mybean" is not defined in this page.

for what it is

my directoy structure is:

context/
index.html
view.jsp
WEB-INF/
web.xml
classes/
mvc/
Controller.class
Mybean.class.

this is the my mvc application directory structure.but it is not working now also.why?
Balasubramani Dharmalingam
Ranch Hand

Joined: Dec 06, 2004
Posts: 116

my directoy structure is:

context/
index.html
view.jsp
WEB-INF/
web.xml
classes/
mvc/
Controller.class
Mybean.class.

place your mybean class under
WEB_INF/classes/mvc/beans directory.


Balasubramani SD,<br />SCJP 1.4,SCWCD 1.4,SCJP 5.0<br /><a href="http://sd.balasubramani.googlepages.com" target="_blank" rel="nofollow">www.sd.balasubramani.googlepages.com</a>
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114


i changed the package location for bean from "mvc.benas" to "mvc" only.that's why i put in the "mvc" package which is under "classes" folder which is under web-inf.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

So you also changed your jsp to :


?
[ January 11, 2006: Message edited by: Satou kurinosuke ]

[My Blog]
All roads lead to JavaRanch
Shrinivas Mujumdar
Ranch Hand

Joined: Aug 27, 2004
Posts: 328
same issue since same kind of mistake

you are using expression how it will return you something it will dispaly it on the page

use EL/Scriptlet given earlier if you want to retrive the value
Shrinivas
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

1. Are you forwading/including from another Jsp file ?
2. Which web server are you using ?
[ January 11, 2006: Message edited by: Satou kurinosuke ]
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114


yes i changed like above.


yes ,
value=<%=mybean.getFirstname()%> like this i changed.

1.yes i am forwarding to the servlet.
2.weblogic server 8.1 i am using.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

I don't know if this is a Weblogic problem,
but I've seen people using WebLogic and complaining about the same problem.
Did you try it with Tomcat ?
Did you install the Service Pack for Weblogic ?
narayana arya
Greenhorn

Joined: Dec 12, 2005
Posts: 12
just change the scope of the bean as application.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Shrinivas Mujumdar:

or (if JSP 2.0 is supproted by your server)

I hope this helps

Do focus on suggestions given earlier related to code conventions

Shrinivas



There is nothing wrong with the way he was using the jsp:getProperty tag.
He wasn't trying to assign a value to a Java varible, he was using it to print the value into an HTML input tag.




Babu,

This thread has become very confusing with all the changes to your code.
Please re-post your JSP code, bean code, and web.xml file.
Also, please re-post your directory structures so we can see where your files are.
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hello myfriends,

thanks all,i got the solution ,now it is working.the problem is i am using jdk1.5.0_01 version for to compile the bean.so the class file version is 49.0.but jre doesn't recognise the 49.0 version classfile which delivered by jdk1.5.0 compiler,so it is giving message is should use 48.0 version.

so i compiled the .java files with jdk1.4 ,because jdk1.4 compiler will deliver 48.0 version class file.again i deployed it is working fine.

again thanks for all of my friends those who gave the replies with patience.

cheers,
babu.
Abhinit Saxena
Greenhorn

Joined: Jan 10, 2006
Posts: 18
Originally posted by Bear Bibeault:


This is not something that I'd consider doing or consider a best practice. Only class files need be placed in the WEB-INF/classes hierarchy.


Sorry modified it from .

put your files in /WEB-INF/src
and compile from there with command

javac [-classpath <chlasspath if any required>] <filename>.java -d ../classes


Now i think you can consider it as a best practice

(but i want to point out one more thing that it may be complicated for a biggener to understand what exactly (s)he is doing...isn't it?? )


but thanks for your point.
A Babu
Ranch Hand

Joined: Nov 28, 2005
Posts: 114
hi friends,
please continue the thread.

upto now i am using the bean as to store the data temporarily.now i want to store the data in the database how it is.please tell me where i need to put connection code ,where i need to develop the connection code.please tell me i am waiting for reply.

cheers,
babu.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error occuring while use jsp