Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

access file ?

 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
suppose I made one javabean file in classes.. so can I access it it JSP.. without using <jsp:useBean > standard actions ?
should I give any import statement for that ?
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make use of a servlet.
 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ya .I am using servlet.. but I want to show data in JSP.. so there are bean getters method from which I can show data to JSP.
but in JSP its giving me an error.. for Bean class not found ....
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In detail:
1) Create a servlet and map it on a certain url-pattern.
2) Let the servlet do the same work as jsp:usebean (check/instantiate a bean in the desired scope).
3) Either let the url-pattern cover the JSP page in question or let the servlet forward the request to the JSP page in question.
4) In the JSP page you can just access the bean using EL the usual way.
 
Saurabh Naik
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes correct but my problem is in the last step as you mentioned

the error is
org.apache.jasper.JasperException: Unable to compile class for JSP

An error occurred at line: 14 in the jsp file: /myshoppingcart.jsp
ShoppingBean cannot be resolved to a type

I guess in Jsp there is problem for accessing Bean.

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're likely doing it completely wrong.

In the servlet you just do like the following:

and in the JSP you can just access it by
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic