*
The moose likes JSP and the fly likes access file ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "access file ?" Watch "access file ?" New topic
Author

access file ?

Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
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 ?


SCJP 6 (88%), SCWCD 5 (78%), preparing for SCBCD
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Make use of a servlet.
Saurabh Naik
Ranch Hand

Joined: Apr 24, 2008
Posts: 87
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

Joined: Oct 08, 2006
Posts: 2458
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

Joined: Apr 24, 2008
Posts: 87
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

Joined: Oct 08, 2006
Posts: 2458
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: access file ?
 
Similar Threads
How can I replace the line of file?
EL not working
vista file permissions
db file
Problems with ResultSetMetaData getTableName()