aspose file tools*
The moose likes JSP and the fly likes problem in jsp !!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "problem in jsp !!!" Watch "problem in jsp !!!" New topic
Author

problem in jsp !!!

ramakrishna pydipati
Greenhorn

Joined: Oct 13, 2003
Posts: 23
Hai everybody,
I m getting the problem in jsp so please help me out!!!
<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
<HTML>
<HEAD>
<TITLE>Invoice process </TITLE>
</HEAD>
<BODY>

<tr><td align=right><h2> Item Unit price Quantity SubTotal </h2></td>
</tr><br><br>
<%!
String x="0";
String y="0";
String z="0";
double t1;
double t2;
double t3;

%>
<%

x = request.getParameter("cd");
y= request.getParameter("flopy");
z = request.getParameter("cdmusic");

t1 = (Integer.parseInt(x)) * 0.50;
t2 = (Integer.parseInt(y)) * 10.99;
t3 = (Integer.parseInt(z)) * 15.50;

%>
CDR $0.50 <%= t1 %><br><br>

Disks$10.99 <%= t2 %><br><br>

Music$15.50 <%= t3 %><br>

</BODY>
</HTML>
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Originally posted by ramakrishna pydipati:
please help me out!!!

Sure. But how can you expect people to help you, when you don't tell what the problem is!?


Mani
Quaerendo Invenietis
ramakrishna pydipati
Greenhorn

Joined: Oct 13, 2003
Posts: 23
hai sorry about it.
it is giving null error.
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
I think, the attributes cd, flopy & cdmusic are not set properly.
How are you calling the JSP? Straight from the browser or from a different JSP or Servlet?
ramakrishna pydipati
Greenhorn

Joined: Oct 13, 2003
Posts: 23
I am calling from HTML page (project6.html)
<HTML>
<HEAD>
<TITLE>Invoice</TITLE>
</HEAD>
<BODY>
<form action="project6.jsp" method="POST" >

<table align=center >
<tr><td align=right> Specify the quantity you want to buy :</td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
<tr><td align=left>CD Writer: $0.50/each</td>
<td align=left><input type=text name="cd" size=7></td>
</tr>
<tr><td align=left>Floppy Disks: $10.99/package:</td>
<td align=left><input type=text name="flopy" size=7></td>
</tr>
<tr><td align=left>Music CD: $15.50/each</td>
<td align=left><input type=text name="cdmusic" size=7></td>
</tr>
<tr><td colspan=2 align=right><input type=submit value="Submit">
<input type=reset value="Reset"></td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
</table>
</form>
</BODY>
</HTML>
Mani Ram
Ranch Hand

Joined: Mar 11, 2002
Posts: 1140
Mmmm...I don't find any problem with the code. :roll:
Is it happening always or only if you leave any of the input field empty? And make sure that all the names or spelled in the same way in both JSP & HTML (for example, is it flopy in both JSP & HTML?)
Probably you can paste the entire exception.
ramakrishna pydipati
Greenhorn

Joined: Oct 13, 2003
Posts: 23
always it is giving out put as 0 in jsp page and nothing is getting printed
in html page.
this is my htmlpg:
<HTML>
<HEAD>
<TITLE>Invoice</TITLE>
</HEAD>
<BODY>
<form action="project6.jsp" method="POST" >

<table align=center >
<tr><td align=right> Specify the quantity you want to buy :</td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
<tr><td align=left>CD Writer: $0.50/each</td>
<td align=left><input type=text name="cd" size=7></td>
</tr>
<tr><td align=left>Floppy Disks: $10.99/package:</td>
<td align=left><input type=text name="flopy" size=7></td>
</tr>
<tr><td align=left>Music CD: $15.50/each</td>
<td align=left><input type=text name="cdmusic" size=7></td>
</tr>
<tr><td colspan=2 align=right><input type=submit value="Submit">
<input type=reset value="Reset"></td>
</tr>
<tr><td colspan=2><hr width=400></td>
</tr>
</table>
</form>
</BODY>
</HTML>
this is jsp page:
<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
<HTML>
<HEAD>
<TITLE>Invoice process </TITLE>
</HEAD>
<BODY>

<tr><td align=right><h2> Item Unit price Quantity SubTotal </h2></td>
</tr><br><br>
<%!
String x;
String y;
String z;
double t1;
double t2;
double t3;

%>
<%

x = request.getParameter("cd");
if (request.getParameter("cd")!=null)
{
x= request.getParameter("cd");}
else
{
x= "0";
}

y= request.getParameter("flopy");
if (request.getParameter("flopy")!=null)
{
y= request.getParameter("flopy");}
else
{
y= "0";
}
z = request.getParameter("cdmusic");
if (request.getParameter("cdmusic")!=null)
{
z= request.getParameter("cdmusic");}
else
{
z= "0";
}

%>

<%
t1 = (Integer.parseInt(x)) * 0.50;
t2 = (Integer.parseInt(y)) * 10.99;
t3 = (Integer.parseInt(z)) * 15.50;
%>

CDR $0.50: <%= t1 %><br><br>

Disks$10.99: <%= t2 %><br><br>

Music$15.50: <%= t3 %><br>

</BODY>
</HTML>
Jan Figo
Greenhorn

Joined: Nov 26, 2003
Posts: 9
nothing wrong with the code html and jsp... tried on my mc.. works well
no problems about that,
i am using Tomcat 4.0.


Take life as it comes!!!<br />~jan
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

<%@ page language ="java"%>
<%@ page import = "java.io.*"%>
========
In a single page u cannotgive mor than one page directive declaration...


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61413
    
  67

In a single page u cannotgive mor than one page directive declaration...

That is not correct. There are some clauses that you cannot repeat (such as language), but you can have as many page directives as you want for the repeatable clauses such as import.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nagaseshagiri poola
Greenhorn

Joined: Oct 18, 2003
Posts: 25
Hi
I tested your pages and currently iam using Tomcat4.1 and its working fine and i dont find any null error.
may be you need to check once again and what server are you using now.
have a nice time
Anselm Paulinus
Ranch Hand

Joined: Sep 05, 2003
Posts: 389
Hi ramakrishna pydipati :
I advice you put print statement in your code to enable you know precisely which variable is throwing the null pointer exception; that will help you resolve the problem.
anselm
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in jsp !!!