• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error occuring while use jsp

 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you also changed your jsp to :


?
[ January 11, 2006: Message edited by: Satou kurinosuke ]
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ?
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
just change the scope of the bean as application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic