Why we should use JSP instead of Servlet ?
I want to know what are the advantages to use JSP over Servlet.
hi
Servlets are server exctension ( like CGI ) separate executable
modules to serve any request efficiently.
Servlets are pure java classes, u can use them the write an html code to browser.
u have to compile the servlet before u use it.
JSP page, is a text-base document , u can type html inside it , and u can use java as scripting language, so it is more easy to use jsp rather than servlet as each jsp page is translated into a servlet by JSP engine.
Hope this will help
Good luck
Mohammed
Similar Messages
-
Why do we use jsp instead of servlet
why do we use jsp instead of servlet
Hi,
I am and web/Java developer and have used a mixture of JSPs and servlets. I use JSPs for my actual web pages. Whether they are displaying dynamic database driven content or simple pages doing nothing but password protecting.
I tend to separate other reusable code into servlets, like database connections and business logic.
For example: I have worked on a mortgage site and there quite a lot that goes into calculating a monthly payment and ARP. These calculations will not change (only values I send to them will) therefore I do this type of coding in a servlet.
Cheers
Mark
:o) -
Why do we use jap instead of servlet
why do we use jap instead of servlet
JSPs are compiled into servlets. Use them to more conveniently generate presentation code such as HTML. With a JSP, you can code the HTML directly, no need for lots of "out.println" statements. JSPs can be written by non-programmers who don't know Java using the built-in JSP features plus custom tags libraries.
-
Why I should use an iCloud mailbox?
Hello there. I discovered that now I can use a @icloud.com mail address simply enabling it from my iCloud preference panel in OS X. I have created an email address, but I have some questions:
What happens to my @icloud.com address if I don't use a Mac (or iPhone, iPad, etc.) anymore?
Will my iCloud mail be available forever from icloud website or using IMAP configuration?
What is the maximum space granted?
The final question is: why I should use an iCloud mailbox instead (for example) of a Gmail one? All contributes will be greatly appreciated!1) Nothing
2) Yes, as long as Apple keeps the service going
3) 5Gb for free. More if you pay.
4) It's up to you. iCloud email supports push notifications on iOS devices. That's about the only difference compared to any other IMAP email account. iCloud also syncs and backs up iOS devices. -
I cannot use a website I need to use, with Firefox 5.0. So, I need to uninstall and go back to 3.5 or 3.6. Please advise. Also, my control panel locks up since Windows Explorer has pbms. Which is why I am using Firefox instead. Thanks for any help!
''I figured it was going to be FAFSA causing your problem.''
Install Portable Firefox 3.6.x to your hard drive for that one website. It won't affect your current Firefox installation at all. <br />
http://portableapps.com/apps/internet/firefox_portable/localization#legacy36 -
Why we should use Macros if we have function Module
Why we should use Macros if we have function Module and what is the Advantage of Macros than function Module
Moderator Message: Interview-type questions are not allowed.
Edited by: kishan P on Oct 7, 2010 2:22 PMPut it this way... if you have blueprints for a car you wouldn't want to produce only one car, would you? You would want to produce as many as needed. In another example, you don't want to be able to use only 1 window in Windows. Each window has common features but have different values. That's the purpose of non-static entities
However, there are instances that you want to have only one value for something. That's when you use static entities.
Get it? =) -
Why we should use Statis entities?
If we can access Static entities directly without creating instances, then why we should use None-Static entities? None Static entities are occupying resources too.
Is there any disadvantage of Static entities?Put it this way... if you have blueprints for a car you wouldn't want to produce only one car, would you? You would want to produce as many as needed. In another example, you don't want to be able to use only 1 window in Windows. Each window has common features but have different values. That's the purpose of non-static entities
However, there are instances that you want to have only one value for something. That's when you use static entities.
Get it? =) -
In this tutorial
http://www.asp.net/mvc/overview/older-versions/getting-started-with-aspnet-mvc3/cs/adding-a-new-field
I see such code
public class MovieInitializer : DropCreateDatabaseIfModelChanges<MovieDBContext> {
protected override void Seed(MovieDBContext context) {
var movies = new List<Movie> {
new Movie { Title = "When Harry Met Sally",
ReleaseDate=DateTime.Parse("1989-1-11"),
Genre="Romantic Comedy",
Rating="R",
Price=7.99M},
new Movie { Title = "Ghostbusters ",
ReleaseDate=DateTime.Parse("1984-3-13"),
Genre="Comedy",
Rating="R",
Price=8.99M},
new Movie { Title = "Ghostbusters 2",
ReleaseDate=DateTime.Parse("1986-2-23"),
Genre="Comedy",
Rating="R",
Price=9.99M},
new Movie { Title = "Rio Bravo",
ReleaseDate=DateTime.Parse("1959-4-15"),
Genre="Western",
Rating="R",
Price=3.99M},
movies.ForEach(d => context.Movies.Add(d));
But when I went to https://msdn.microsoft.com/en-us/data/ee712907 I see only migration database
I am newbie at EF. I am focusing on Code First. I have an idea that
DropCreateDatabaseIfModelChanges
and another DataBase initializer is not acutal for EF 6 but it was used in previous version.
On the other hand from names of this
Database initializer is for database initization
Migration for database structure changing
Before learning I decided ask this question
Does Database initializer obsolete in EF 6.0 ? And I should use Database Migration instead of it ?
My .NET Blog with projects and feedback.
Since May 30, 2014 I am waiting for Microsoft fix
these 2 bug. If you know how to speed them up, please helpHello,
>>Does Database initializer obsolete in EF 6.0?
I do not know why you think so, if the team decides to make the database initializer obsolete, I think they would make a markup as Deprecated, however, there is not such a markup on that method on MSDN document. And the Database initializer method is useful
when we play with automatic migration. In your case, the DropCreateDatabaseIfModelChanges database initialization strategy, would delete the original database and create new one according your new model. Of course, data would be missing. If you are under a
scenario need to make a test to recreate the database frequently, this one should be ok.
Currently, there are four database initialization strategies could be used:
CreateDatabaseIfNotExists<TContext> Class
DropCreateDatabaseAlways<TContext>
DropCreateDatabaseIfModelChanges<TContext>
MigrateDatabaseToLatestVersion<TContext, TMigrationsConfiguration>
You could use one of them for a proper scenario.
Regards.
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Why do you use jsp:useBean?
Hi,
I have one "simple" question :) : When or why do you are using <jsp:useBean>,<jsp:getProperty> and <jsp:setProperty>?
For practice, I am creating a form, sends the data to a servlet and the servlet "packs" the parameter into a Bean and put this Bean into a request- or SessionScope. After that, my resultpage could access the property name of the bean with (for instance) sessionScope.Bean.name.
I wanted to use the 3 tags above first, but after I realised the way I describes above I didn't have to use these three jsp tags. Therefore I wonder when you are using these tags.
Thnx
Alexhi
The component model for JSP technology is based on JavaBeans component architecture. JavaBeans components are nothing but Java objects which follow a well-defined design/naming pattern: the bean encapsulates its properties by declaring them private and provides public accessor (getter/setter) methods for reading and modifying their values.
Before you can access a bean within a JSP page, it is necessary to identify the bean and obtain a reference to it. The <jsp:useBean> tag tries to obtain a reference to an existing instance using the specified id and scope, as the bean may have been previously created and placed into the session or application scope from within a different JSP page. The bean is newly instantiated using the Java class name specified through the class attribute only if a reference was not obtained from the specified scope. Consider the tag:
sun site -
Why does people use JSP Tag for their JSP page? (Urgent)
I don't know what benifit if I am using JSP Tag.
If anyone knows, pls give me an idea and the advantage of using JSP Tag in JSP Page!
Thanks in advance!You have to read a little about JSP, JSP stands for JavaServer Pages, you can use jsp tags and you can use java code. If you dont want to use jsp tags then you should just write html file, if you just want to use java, then write java class or a servlet.
The need for jsp arised because people were inserting html code inside a servlet class..a big no no..and a headache. JSP separate model from the view...read a little about MVC-2 model view controller pattern.
Also read some tutorial on this website...good luck
K -
Need Help Badly on Shopping Cart Using JSP And Java Servlet
Hi All,
This is the 1st time i am trying to create a shopping cart using JSP and Servlet.
I have read through a few acticles but i still do not get the whole idea of how it works.
Please guide me as i need help very badly.
Thanks.
This is one of the jsp page which displays the category of products user would like to buy : Products.jsp
<html>
<head>
<title>Purchase Order</title>
</head>
<body topmargin="30">
<table border="0" width="100%" id="table1" cellpadding="2">
<tr>
<td bgcolor="#990000" width="96">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Code</font></b></td>
<td bgcolor="#990000" width="260">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Description </font></b></td>
<td bgcolor="#990000" width="130">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Brand
</font></b></td>
<td bgcolor="#990000" width="146">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">UOM
</font></b></td>
<td bgcolor="#990000" width="57">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Unit<br>
Price </font></b></td>
<td bgcolor="#990000" width="62">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Carton<br>
Price </font></b></td>
<td bgcolor="#990000" width="36">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">
Qty</font></b></td>
<td bgcolor="#990000" width="65">
<p align="center"><b><font face="Verdana" size="2" color="#FFFFFF">Add<br>
To Cart</font></b></td>
</tr>
<tr>
<td align="center" width="96" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">123</font>
</td>
<td align="center" width="260" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Tom Yam</font>
</td>
<td align="center" width="130" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">Nissin</font>
</td>
<td align="center" width="146" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">12 x 10's</font>
</td>
<td align="center" width="57" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">$3.85</font>
</td>
<td align="center" width="62" bgcolor="#CCCCCC">
<font face="Verdana, Arial, Helvetica, sans-serif" size="2">$46.2</font>
</td>
<td align="center" width="36" bgcolor="#CCCCCC">
<!--webbot bot="Validation" S-Data-Type="Integer" S-Number-Separators="x" -->
<p align="center"><input type="Integer" name="Q10005" size="1"></p>
</td>
<td align="center" width="65" bgcolor="#CCCCCC">
<p><input type="checkbox" name="checkbox" value="123"></p>
</tr>
<tr>
</table>
<table border="0" width="100%" id="table2">
<tr>
<td>
<div align="right">
<input type="hidden" name="hAction" value="AddToCart"/>
<input type=submit name="submit" value="Add To Cart"/>
</div>
</td>
</tr>
</table>
</body>
</html>
After user has make his selection by entering the qty and ticking on the check box, he would click the "Add To Cart" button ... and this would call my servlet : AddToAddControlSerlvet.java
import javax.servlet.http.*;
import javax.servlet.*;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
public class AddToCartControlServlet extends HttpServlet
public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException
String action = req.getParameter("hAction");
if (action.equals("AddToCart"))
addToCart(req,res);
public void addToCart(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException
try
String url = "";
String[] addList = req.getParameterValues("checkbox");
HttpSession sess = req.getSession(true);
//String sessionID = sess.getId();
DBClass dbClass = new DBClass();
ArrayList cartList = new ArrayList();
for (int i = 0; i < addList.length; i++)
String productCode = (String)addList;
int qty = Integer.parseInt(req.getParameter("Q"+productCode));
Products product = dbClass.getProductDetail(productCode);
double totalUnitAmt = qty * product.getUnitPrice();
double totalCartonAmt = qty * product.getCartonPrice();
Order order = new Order(product.getProductCode(),product.getProductDesc(),product.getBrandName(),product.getUom(),qty,product.getUnitPrice(),product.getCartonPrice(),totalUnitAmt,totalCartonAmt);
cartList.add(order);
sess.setAttribute("cartList", cartList);
url = "/Cart/CartDetails.jsp";
ServletContext sc = getServletContext();
RequestDispatcher rd = sc.getRequestDispatcher(url);
rd.forward(req, res);
catch (Exception e)
System.out.println(e);
From here, i would get the list of items which user has selected and add to the cartList, then i would direct the user to CartDetails.jsp which displayed the items user has selected.
From there, user would be able to remove or to continue shopping by selecting other category.
How i do store all the items user has selected ... everytime he would wan to view his cart ...
As i would be calling from jsp to servlet .. or jsp to servlet ... and i do not know how i should go about in creating the shopping cart.Hi !
Yon can use a data structure as vector and store the items selected by the user into the vector . Keep the vector in session using session object , so the user can access the entire shopping cart from anywhere in the application .
Then , you can change the cart accordingly .
Hope this works.
Cheers ,
Pranav -
Any reason why I should use Safari on my PC
I use Mozilla now. I now have an Iphone. Is there any reason why I should download and use Safari on my PC? I expect the functions will be different from IE or Mozilla or maybe better, but is it a good idea to download and use since I have an Iphone?
It's pretty irrelevant, unless you really want to sync bookmarks from your computer to your iPhone (you could do that with IE as well, but not Firefox).
-
Why we should use a NTSC or PAL Monitor?
if we are outputting to video for broadcast on tv, so we use a monitor to monitor the colour.(Only for the colour, or some other purpose?)
but if i just make it for web, 3G, and DVD? do i still need TV monitor?
How about HD?
if i use a HD monitor to edit a project, and for broadcast on HDTV, do i still need a HD monitor or sth, else?
Thank you guys!By viewing the material on the final output display device, you prevent nasty surprises.
Video is interlaced, computers are progressive.
Video has a different gamma than computers (and macs are different than PCs).
NLE programs show you a proxy image, not the full resolution one.
If you work in HD (and HDV is a low end flavor of HD), you have much more expensive monitoring issues as you can't feed your NTSC/PAL monitor via firewire like you can with DV. You need a 3rd party card like the Kona LH or an external box like the Matrox MXO to convert the computer image to a HDTV image.
Viewing the work in progress on the appropriate monitor gives you on going quality control and the greatest confidence in your output. Other than that, no reason to use an external monitor.
x
Message was edited by: Studio X -
Hi Friends, Please help me to understand Why we are using CHARM instead of
Hi friends,
I am working as SAP security consultant.
I am fresher and worked in implemetaion project.
My question is when i was in implementation project i used CHARM in sol man to create transport request.
Now i am working in support and here we are not using CHARM simply creating transport in PFCG.
So is there any specific difference between both.
Please tell meHi
CHARM is a specific functionality in Solution Manager
so it doesn't mean in all your project or customer are using solution manager charms functionality
therefore you will creating TR from Se09 etc not from UC/NC scenario
Hope clarified your doubt
regards
Prakhar -
What is web.xml and why it is used?
hi,
am new to servlet technology, i tried to find a topic like this in this fourm also in google but didn't get a exact one. can anybody explain me or suggest me some resource about this.
thanx in advance.
Maxhi stevejluke,
thanx for the correct link.
nx for the correct link. but what i in doubt with is
why we should use web.xml? may be my question is very
silly, may be too basic, forgive me for that...
Thanx & Regards,
SaikatAt the most basic level:
There are several versions of the Servlet specification, You need the web.xml to tell the server which version of the spec your application conforms to so the server knows how to deal with different things.
If you have a servlet, you also need the web.xml to define what URL signals a request that should be handled by your servlet.
At this point, you need to sit down and read a book. Do what it says, blindly at first. Just do what it says (but do try to understand the 'what' of it, just don't question the 'why'). After you have a few applications running, go back and ask yourself this question again and try to see what you are using the web.xml for in those applications you have.
Maybe you are looking for
-
Transferring photos from a Canon to my Mac
I recently bought a Canon Power Shot. I have used it and transferred photos to my Mac and didnt have any problems. Now all of a sudden, I turned it on, to import the pictures to the computer, and the camera just turns itself off and the Mac says no
-
Can't print A4 documents adobe reader 10.1.3
Hi Guys, I have a strange problem where I cannot change the default page size. All other programs print ok to A4 the problem lies within adobe reader 10.1.3. Let me run you through what happens exactly when I try. I open a pdf document and go to prin
-
Yesterday I reset my phone, but for some reason the loading bar kept getting to about 3/4's of the way and then freezing. This has never happened before. I left it for a few hours and it had still made no progress. I've tried thousands of battery pul
-
Please help me.. What can I do to get my laptop up and running again?
-
Change text for standard button
Hi, Anyone has an idea of how to change the text of a standard button, e.g. the Go button of the advanced search header. TIA Shane