This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

error occuring while use jsp

 
A Babu
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • 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.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Abhinit Saxena
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64844
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
Shrinivas Mujumdar
Ranch Hand
Posts: 328
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Balasubramani Dharmalingam
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • 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
  • 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.
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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 Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • 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 ?
 
narayana arya
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just change the scope of the bean as application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic