Architecture Question: Servlet, Bean, or JSP?
I've found that alot of the time, the systems I'm trying to design can use all of these to accomplish the same task. What's a good indicator of whether or not I should be using one technology over another?
For example, most recently, I designed an html form that is used to create registration html forms for clients. I can send the data in my form to another jsp page, a servlet, or a bean. ALL THREE can accept the date and use BufferedWriter to create and write to the registration form. Why would I want to use one over the other?
Any help here would be greatly appreciated. I am seriously lacking in proper system design knowledge.
The concept of JSPs was created to let Web designers design pages and developers to plug in the dynamic content. So essentially the JSPs are primarily for display on.
Servlets are good for controlling the flow.
Typically in any medium to large application, that's the distinction you'd want to have.
So have a single controller servlet as a central entry point into your application. That's useful for certain validations such as login etc. Then the servlet performs whatever work is required and dispatches to a JSP to display the output of the work.
Similar Messages
-
Servlet, Bean, or JSP?
I've found that alot of the time, the systems I'm trying to design can use all of these to accomplish the same task. What's a good indicator of whether or not I should be using one technology over another?
For example, most recently, I designed an html form that is used to create registration html forms for clients. I can send the data in my form to another jsp page, a servlet, or a bean. ALL THREE can accept the date and use BufferedWriter to create and write to the registration form. Why would I want to use one over the other?
Any help here would be greatly appreciated. I am seriously lacking in proper system design knowledge.I think you understand that JSP is compiled to a servlet and executed by the server. Ya it goes on behind the scenes.
Hence JSP is a servlet but except for the fact that it makes your life easier by seperating the business logic from UI (ie HTML tags logic) to a greater extent.
And when you have lot of business logic which will be reused and more formally sturtured then take that part to a Java Bean.
Hence my suggestion goes that you write a JSP and any set of repeatable Java code or more of a Bussiness logic take it to the java bean(as java bean is just java classes). JSP should be having HTML tags and calling methods on the Javabean(which will typically connect to the database , or perform operations) which returns the results to the JSP.
Hope this help you out. -
The relation of Servlet , bean and jsp
servlet can output to IE directly? I mean that design a servlet adding some code in the service method, compile it, input URL: localhost:8080/test/servletname, can I get result? (Tomcat, register servlet in web.xml)
yes that's the point!
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class HelloWorld extends HttpServlet {
public void doGet( HttpServletRequest req, HttpServletResponse resp )
throws ServletException, IOException {
resp.getWriter().println( "<html><body>Hello World</body></html>" );
} -
Hi frnds i want to help in servlet,java bean and JSP
hi friends i'm right now in M.SC(IT) and i want to do project in SERVLET,,JAVA BEANS and JSP ,
so pls give me a title about that
NOTE: I develop a project in group(2 persons there)
my email id is : [email protected] , [email protected] , [email protected]You cannot pair your iPod to a cell phone, so forget about it.
The only way you can get free WiFi is to hang out at a Denny's, a Starbucks, or a truck stop, and I don't think your parents would approve.... -
Please help!
I have a servlet controller, a javabean for the data and a jsp for the view.
I cannot get the jsp using
<jsp:useBean id="pList" class="bbs.PostListCommand" scope="request" />
to access the bean data
However, when I access the bean in this way
<%@ page import="bbs.PostListCommand" %>
// html
<% bbs.PostListCommand postList = null;
synchronized(session){
postList = (bbs.PostListCommand) session.getAttribute("PostListCommand");
if (postList == null){ %>
<H1>Nothing in request scope to retrieve ....</H1>
<P>
<% }
else{ %>
<TABLE border="1">
// etc
� it works
Does anyone know why the <jsp:useBean> tag does not find the bean
I have installed tomcat 4.18 and set the environmental variables etc.
Directory structure is
E:\Tomcat41\webapps\examples\WEB-INF\jsp for jsp�s
E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs for bean and servlets
Thanks in advance for any help.
ChrisGrayMan - Thanks for your help.
Let me explain my problem in more detail ...
Background:
I have some servlet experience, but I am new to jsp - so sorry if this seems trivial to you ...
I have a book called bitter java by bruce tate from manning.com . I am trying to get the chapter 3 examples to work
There are three files
PostListCommand the bean
PostListController the servlet
PostListResults jsp
And a new test file � PostListResults version 2 with scriptlet code to access the bean.
There are a couple of typos in the downloaded source files, but nothing that causes the main problem of not being able to access the bean data.
Program flow
Servlet instantiates new bean
Bean � gets data from db
Servlet passes bean to jsp with a forward
Jsp outputs data
I have put the files in the directories �
E:\Tomcat41\webapps\examples\WEB-INF\jsp for jsp�s
E:\Tomcat41\webapps\examples\WEB-INF\classes\bbs for bean and servlets
The complete source code for each file is given below.
1 I have checked the db access � that�s ok
2 I have also checked reading the bean data back in from the request scope and printing out the results from within the servlet.- ok
3 I can access the data through a scriptlet (PostListResults version 2), but not with the original PostListResults which uses <jsp:useBean>
thanks in advance, chris
PostListController.java
package bbs;
// Imports
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
// Import for commands used by this class
import bbs.PostListCommand;
public class PostListController
extends javax.servlet.http.HttpServlet
implements Serializable {
* DoGet
* Pass get requests through to PerformTask
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws javax.servlet.ServletException, java.io.IOException {
performTask(request, response);
public void performTask(
HttpServletRequest request,
HttpServletResponse response) {
try {
PostListCommand postList = (bbs.PostListCommand) java.beans.Beans.instantiate(getClass().getClassLoader(),"bbs.PostListCommand");
postList.initialize();
postList.execute();
request.setAttribute("PostListCommand", postList);
ServletContext sc = this.getServletContext();
RequestDispatcher rd =
sc.getRequestDispatcher("/jsp/PostListResults.jsp");
rd.forward(request, response);
} catch (Throwable theException) {
theException.printStackTrace();
PostListCommand.java
package bbs;
import java.io.*;
import java.sql.*;
//import COM.ibm.db2.jdbc.*;
import java.util.*;
* Insert the type's description here.
* Creation date: (07/17/2001 5:07:55 PM)
* @author: Administrator
public class PostListCommand {
// Field indexes for command properties
private static final int SUBJECT_COLUMN = 1;
private static final int AUTHOR_COLUMN = 2;
private static final int BOARD_COLUMN = 3;
protected Vector author = new Vector();
protected Vector subject = new Vector();
protected Vector board = new Vector();
// SQL result set
protected ResultSet result;
protected Connection connection = null;
* execute
* This is the work horse method for the command.
* It will execute the query and get the result set.
public void execute()
throws
java.lang.Exception,
java.io.IOException {
try {
// retrieve data from the database
Statement statement = connection.createStatement();
result =
statement.executeQuery("SELECT subject, author, board from posts");
while (result.next()) {
subject.addElement(result.getString(SUBJECT_COLUMN));
author.addElement(result.getString(AUTHOR_COLUMN));
board.addElement(result.getString(BOARD_COLUMN));
result.close();
statement.close();
} catch (Throwable theException) {
theException.printStackTrace();
* getAuthor
* This method will get the author property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getAuthor(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) author.elementAt(index);
* getBoard
* This method will get the board property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getBoard(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) board.elementAt(index);
* getSubject
* This method will get the subject property.
* Since the SQL statement returns a result set,
* we will index the result.
public String getSubject(int index)
throws
java.lang.IndexOutOfBoundsException,
java.lang.ArrayIndexOutOfBoundsException {
return (String) subject.elementAt(index);
* initialize
* This method will connect to the database.
public void initialize()
throws java.io.IOException {
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
// URL is jdbc:db2:dbname
String url = "jdbc:db2:board";
// URL is jdbc:odbc:bitter3board
String url = "jdbc:odbc:bitter3board";
// connect with default id/password
connection = DriverManager.getConnection(url);
} catch (Throwable theException) {
theException.printStackTrace();
* Insert the method's description here.
* Creation date: (07/17/2001 11:38:44 PM)
* @return int
* @exception java.lang.IndexOutOfBoundsException The exception description.
public int getSize() {
return author.size();
PostListResults.jsp
<HTML>
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<H1>All Messages</H1>
<P>
<jsp:useBean id="postList" class="bbs.PostListCommand" scope="request"></jsp:useBean>
<TABLE border="1">
<TR>
<TD>Subject</TD>
<TD>Author</TD>
<TD>Board</TD>
</TR>
<% for (int i=0; i < postList.getSize(); _i++) { %>
<TR> <TD><%=postList.getSubject(_i) %></TD>
<TD><%=postList.getAuthor(_i) %></TD>
<TD><%=postList.getBoard(_i) %></TD>
</TR>
<% } %>
</TABLE>
<P>
</BODY>
</HTML>
PostListResults.jsp version 2 � with scriplet code instead of useBean
<HTML>
<%@ page import="bbs.PostListCommand" %>
<!-- This file was generated by the chris -->
<HEAD>
<TITLE>Message Board Posts</TITLE>
</HEAD>
<BODY BGCOLOR=#C0C0C0>
<% bbs.PostListCommand postList = null;
synchronized(request){
postList = (bbs.PostListCommand) request.getAttribute("PostListCommand");
if (postList == null){ %>
<H1>Nothing in request scope to retrieve ....</H1>
<P>
<% }
else{ %>
<TABLE border="1">
<TR>
<TD>Subject</TD>
<TD>Author</TD>
<TD>Board</TD>
</TR>
<% for (int i=0; i < postList.getSize(); _i++) { %>
<TR> <TD><%=postList.getSubject(_i) %></TD>
<TD><%=postList.getAuthor(_i) %></TD>
<TD><%=postList.getBoard(_i) %></TD>
</TR>
<% } %>
</TABLE>
<% }
}%>
<P>
goodnight
</BODY>
</HTML> -
JSP- Servlet-- Bean-- JSP how to implement
I have problem.
My JSP will take a emplyee id .
Now I want to show all the values regarding that employee in a JSP(JSP form) from the DB(Oracle).
So Iam planning like
JSP-->Servlet-->Bean-->JSP
So my doubts are.
1. Is it correct approach
2.If it is correct then which part of the flow connects to DB and stores the value before putting to JSP.
Iam using Tomcat 4.31
Plz help meI have problem.
My JSP will take a emplyee id .
Now I want to show all the values regarding that
employee in a JSP(JSP form) from the DB(Oracle).
So Iam planning like
JSP-->Servlet-->Bean-->JSP
So my doubts are.
1. Is it correct approach
2.If it is correct then which part of the flow
connects to DB and stores the value before putting to
JSP.
Iam using Tomcat 4.31
Plz help meHI
What you are probably proposing is an MVC design pattern. I wonder if u have heard of the struts framework. Sruts uses MVC design pattern wherein the servlet u are talking about acts as a controller(C) and the bean acts as the model(M) .The JSPs present the view(V). Hence the name MVC.
Your approach is right. First get the employee ID from the jsp and get the corresponding data from database(This logic u implement in the servlet). Then save the fetched data in a bean so that the result jsp can fetch data from it.
Now this is not a strict MVC approach.
Learn more about struts. It presents a much more cleaner solution. -
Sample jsp servlet bean (MVC) code
We want to look into the JSP/Servlet/Bean area for our next project. We wish to understand the technology and as such want to hand build simple applications, and as such do not want to use JDeveloper just yet.
We have searched and searched for suitable material but cannot anywhere find a sample application that :
A. Lists contents of a databse table
B. Each item in trhe list is a link to a page that allows that item, to be edited.
C. A new item can be added.
D. Uses the MVC model of JSP/Servlet and bean (preferably with no custom tags)
There are examples that are too simplistic and do not cover the whole picture. Having spent over 100 GBP on books lately, only to be disappointed with the examples provided, we need to see some sample code.
The samples provided by Oracle are too simplistic. They should really have provided ones built around the EMP and DEPT tables.
Anyone know where we can get hold of this sample code.At the risk of sounding really dumb the examples are just too complex. There does not appear to be anywhere on the web where I can find a simple JSP/servlet/bean example of the type I described. There is enouigh material describing each individual component, but what I need is an example to cement the ideas, but the ones suggested are too much for a newbie. Even the much vaunted Pet Store thingy causes my eyes to glaze over.
I dont expect anyone to have written something with my exact requirements, but surely to goodness there must be something that:
1. On entry presents a search form on a table (e.g. EMP)
2. On submission list all rows in EMp matchiung the criteria.
3. The user can either click the link 'Edit' which opens up a form dispalying the row allowing the user to edit and save the changes, or click the 'New' button to show a blank form to create a new EMP.
All this via a Controller servlet, with the database logic handled by a java bean, and all the presentation done via JSP.
To me this is the most obvious and instructive example of this technology, but after days of trawling the web, and looking through a number of books, I cannot find such a thing.
CGI with Perl DBI/DBD was a breeze to work with compared to this stuff ..... maybe ASP with SQL/Server would be a more fruitful use of time. -
Front controller/database - architecture question
Hello! Thanks for checking out my question! I am pretty new to web services/servlets and jdbc.
I am implementing an application that essentially is an index of reports. I have an index page where a user can click on one of 6 available reports, go to an input page to customize the information being sent into the different queries and then the results of that query will be displayed on the next page. I have two controller servlets.. one for the input pages and another for the output of the queries. I am just curious as to if there should be anything I need to be cautious about when I am coding this. We expect to have no more than 500 users (that is a very high estimate) on the page at a particular time.
My real question is how do I divide the database calls into the program? Should I have a bean for each jsp result page that handles the queries or should I the queries being handled in the controller request? The result of the query is a cachedResultSet and we already have connection pooling set up so the actual database request will only last a short time. I'm just not sure on the best practice as far as these kinds of things go. Do I need to serialize any requests? Should I consider that when I'm writing the servlets/beans/jsps? Thanks in advance for any kind of answers. Have a great day!Hello,
I worked on something similar to this, here's what I did in a nutshell:
One controller servlet takes requests which describes a query. It delegates the request a specific request handling servlet/session ejb pair. Every servlet/ejb pair then handles the request and dispatches the appropriate response.
There was a lot a similar functionality in the way responses were handled by the ejbs and this could all be encapsulated in a base handler ejb that was subclassed.
This worked well for my problem but I have also used struts to accomplish similar tasks, although I still think struts is a bit too heavy weight for most of my work.
I think you can use a similar pattern with oridanry beans an JDBC to accomplish your task.
We expect to have no more than 500 users (that is a very high >estimate) on the page at a particular time.I suspect most platforms will accomadate your users but what platform are you deploying your application on?
Do I need to serialize any requests?I don't think so, but why do you ask, will your application be distributed over multiple servers? -
What is the difference between java direct or java bean in JSP?
What is the difference if I use java code directly in JSP or use java bean in JSP?
Which class to use for receiving the passed parameter from html or java script? Any difference for java code and java bean in the way receiving the passed data?
How can I pass string from jsp to html or java script?it's generally accepted as better design to separate presentation from logic. meaning, the java code in the jsp should be used to support displaying data, as oppsoed to implementing the application - like database access, etc.
when the logic is separated from the presentation, it allows you to reuse logic components within several jsp pages.
if you decide to change the presentation layer in the future (to support wap, for example) you don't need to rewrite your entire application, since the "guts" of the application is outside of the jsps.
it is also a good idea to separate your business logic from your data layer. adding a "buffer zone" between these layers helps in the same manner as in separating presentation from logic. if you're using flat files for storage now, upgrading to a database wouldn't require rewriting all your business logic, just the methods which write out the data to a file, for example.
once you feel comfortable with separating the various layers, check out the struts framework at http://jakarta.apache.org/
to answer your second question, to get parameters passed in from HTML forms, use ServletRequet's getParameter() method.
in tomcat:
<% String lastName = request.getParameter( "lastname" ); %>
to answer your third question: when displaying the HTML from withing a jsp, print out the string to a javascript variable or a hidden form element:
<% String firstName = "mike"; %>
<input type="hidden" name="firstname" value="<%= firstName %>">
<script language="javascript1.2">
var firstName = "<%= firstName %>";
</script>
this jsp results in the following html:
<input type="hidden" name="firstname" value="mike">
<script language="javascript1.2">
var firstName = "mike";
</script> -
Tomcat 6 Calling a Java Servlet from a JSP Page
Below is a very simple JSP Page that calls a Java Servlet. The question is given Tomcat security constraints, is it possible to call a servlet from a JSP and get the correct output without getting an error message? If so, how would you code the web.xml file?
c:\apache-tomcat-6.0.18
Under conf
catalina
localhost
HelloWorldExample.xml is directly under localhost
The application would have this directory structure:
webapps
HelloWorldExample
hello.jsp is directly under HelloWorldExample
Under HelloWorldExample
src
WEB-INF
classes
Under classes
jservlets
HelloWorld.java is in src folder
HelloWorld.class is in jservlets folder
HelloWorldExample.xml
<Context path="/HelloWorldExample" docBase="HelloWorldExample" debug="0"
reloadable="true" crossContext="true">
</Context>**************************
hello.jsp
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<FONT SIZE="4">
<P>
Please enter your name:
<FORM
METHOD="Post"
ACTION="servlet/jservlets.HelloWorld">
<TABLE BORDER="3" CELLPADDING="1" WIDTH="100%" ALIGN="CENTER">
<TR>
<TD><B>Name:</B></TD>
<TD><INPUT TYPE="text" NAME="Name" VALUE="" SIZE="65"> </TD>
</TR>
</TABLE>
<P>
<INPUT TYPE="SUBMIT" VALUE="Submit">
</FORM>
</FONT>
</BODY>
</HTML>******************
HelloWorld.java
package jservlets;
import java.io.*;
import java.util.Date;
import java.util.*;
import java.text.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet
PrintWriter out;
PrintWriter err;
String strName;
public void displayMessage(HttpServletRequest request, HttpServletResponse response)
throws Exception
try
if (!strName.equals("") && strName != null)
out.println("Hello " + strName + "" + "<P>");
out.println("Hello World" + "<P>");
else
out.println("Hello World" + "<P>");
catch (Exception e)
out.println("Exception: Could not display message." + "<P>");
err.println (e.getMessage () ) ;
out.println("<P>");
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
try
response.setContentType("text/html");
out = response.getWriter();
err = response.getWriter();
strName = request.getParameter("Name").trim();
out.println("<html><head><title>");
out.println("</title></head><body>");
out.println("<FORM");
out.println("METHOD=POST");
out.println("ACTION=http://localhost:8080/HelloWorldExample/hello.jsp>");
out.println("<TABLE ALIGN='RIGHT'>");
out.println("<TR>");
out.println("<TD>");
out.println("<INPUT TYPE=\"SUBMIT\" VALUE=\"Hello World Page\";>");
out.println("</INPUT>");
out.println("</TD>");
out.println("</TR>");
out.println("</TABLE>");
out.println("</FORM>");
out.println("<BR CLEAR='all'>");
out.println("<P>");
displayMessage(request, response);
out.close();
out.println("</body></html>");
catch(Throwable e)
e.printStackTrace();
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
doPost(request, response);
web.xml
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>jservlets.HelloWorld</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/servlet/HelloWorld</url-pattern>
</servlet-mapping> ******************************
HelloWorld.java can be compiled by using javac.
Once compiled, HelloWorld.class would be moved to the jservlets folder.
FYI, coding the above url-pattern results in:
HTTP Status 404
The requested resource (/HelloWorldExample/servlet/jservlets.HelloWorld) is not available
The following url-pattern in the web.xml file permits the servlet to be executed but results in a null pointer exception:
<servlet-mapping>
<servlet-name>HelloWorld</servlet-name>
<url-pattern>/ </url-pattern>
</servlet-mapping> **************************************************
RobinThis problem was resolved.
In hello.jsp
ACTION="servlet/jservlets.HelloWorld">
was replaced with
ACTION="servlet/HelloWorld">
Robin -
Hi all,
i am new to servlet and Beans.I am facing a problem currently i have designed a JSP page for adding user information after submitting the information i am calling a servlet from that JSP page to submitt data to the data base which is MYsql,i have made a bean namely DatabaseConnection to connect to the database.,the submission of data is working fine.
the problem i am facing is in displaying the data from the database.again we have made a servlet to fetch data from the database we are using a Bean to set the data in to beans ,currently we are passing the RecordSet as an argument to the SetData function in the bean which is setting the data in the bean variables. At the end of the servlet i,e after setting the data in the beans we are forwarind the controll to the Display.JSP form using request dispatcher method .In the Display form we are using <use:Jsp beans> tage and <get property tag> but unable to show any data it's showing null there.
i need help if some body guide me to the right track...
Thanks in advance
umeshawasss..
Y dont u send ur jsp which used jsp:use bean tag? Hope u are setting the bean correctly in the request or seesion scope from the servlet before commin to jsp.. :)
regards
Shanu -
hello friends,
i'm new to jsp. i want to create an html form that accepts username and a value from four radio buttons and display back the entered name and checked radio button's value using java bean.
i use the <jsp:setProperty id="" property="*"> method. i don't know how to access the radio buttons value from the html.
also when i use an additional field other than username the jsp page is showing error.
Please give me the correct method to use java bean with jsp in this circumstance.
thank you.thank you, but i have a problem left. the case is like this.
i got the jsp and bean worked fine when i have a sinle input text field.
but when i added a second text field i recieved the following error.
javax.servlet.ServletException: basket.newbean.getUserPass()Ljava/lang/String;
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:825)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:758)
org.apache.jsp.newform.process_jsp._jspService(process_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:94)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:292)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:236)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
where userPass is the new form element. I have made the subsequent chanes in my bean program and jsp file.
pls hlp. -
Hi guys,
How do I Display a string from a servlet into a JSP Page...
Ive tried so many bloody things!.....
Simply.
I get text from JSP. The servlet does what ever it does to the string.
Now. Ive create sessions and bean things,.... how the hell do I display it in a text box... I can display on the screen.. but not in the text box.!!!
please help!!!hmmm, I dont really like using JSP programming, u should be using JAVA..
the way to do it is:
Call and cast to the bean like this:
<%@ page import="beans.*" %>
<% //cast to bean get request create object
userNameBean u= (userNameBean) request.getSession().getAttribute("userNameBean");
then... all you do is call it like this:
<input type="text" name="firstName" value="<%= u != null? u.getFirstName(): "" %>">
this is the real programmers way,,,
chet.~ -
Using java beans in jsp using tomcat
hi i have made a form to enter user first name and last anme with html and then i have made a value javabean in which i want to store the information filled bu user. i want to display the information stored in java bean in jsp page i have made the full application and i have made class file of java bean as well as jsp file but when i try to run this web application in tomcat i am getting class not found exception.
could anybody tell me that where i should store the bean class in tomcat and do i need to make any package in which i have to place my java bean file plz tell me complete procedure along with code if possiblewhew thats a lot of questions... All of this is pretty basic stuff. I would recommend you take a look at the web services tutorial: http://java.sun.com/j2ee/1.4/docs/tutorial/doc/
lets see.
Starting a package name with com is just a generic standard which is followed.
It is most correct when creating commercial packages to create packages like com.companyName.project
http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html
You should not need a page import directive unless you are using classes in scriptlets: ie <% %> tags in your JSP. Your jsp:useBean tag will automatically import necessary classes - you don't need to import classes for beans specifically
<jsp:useBean id="myClass" scope="session" class="com.myPackage" />
Your directory structure should be something like this
webApplicationRootDirectory
- page1.html
- page2.html
- page3.jsp
- page4.jsp
- WEB-INF
- web.xml
- classes
- com
- myPackage
- myClass.classerrrm. Thats about it I think. -
hi,
I tried to my best to call java beans from JSP page but it generate error that "unable to load class....", please help me that in which directory jsp file and bean *.class file reside, currently my setting are as follows.
Note: I am using tomcat server and my jsp and servlet files are running seccessfuly, there is any special change in classpath for java beans? if any please tell
My jsp file is in tomcat-->webapps-->jsp--><my file>
My bean (*.class) file-->webapps-->Root-->web-inf-->classes--><my file>
Pleae help me for the above problem.
Mubashar ([email protected])According to J2EE standards:
The web appl directory structure should be:
WebAppRootDirectory
|
|---html, jsp, images etc
|
|---WEB-INF---
|---classes--
|---lib
|
|
1) Make sure WEB-INF is in capital letters
2) Place all ur beans in classes dir or sub-directory in
classes
3) In Tomcat place WebAppRootDirectory in webapps
directory
[email protected]
Maybe you are looking for
-
Madness with iTunes 7 !!
Apple how can you mess up this release so badly ? I mean come on didn't you test iTunes 7 properly before releasing this crippled piece of software to the masses ? Isn't itunes first and foremost a software for playing music ?? If it cant even do tha
-
ITunes 10.1.2.17 / 64 Bit Version Distortion
Anyone having issues with distortion with the latest 64 bit version of iTunes? Windows Media Player and VLC play fine, but iTunes sounds over driven and distorted. The 32 bit version of iTunes works fine on my other 32 bit / XP computers.
-
Is anyone facing problems with receiving calls? All my calls suddenly seem to be going into voicemail. I have tried everything possible. Can someone please suggest solutions.
-
Fixing finder list flashing?
My Favorites list in the All My Files window in the Finder is Flashing, How to fix it?
-
In the same way as you can select a default browser for previewing, can you also set a default media player for playing .wmv files on a website? I do not want to use Windows Media Player, but Corel WinDVD9 - the files have been set to open with WinDV