• Post Reply Bookmark Topic Watch Topic
  • New Topic

jsp: forward page problem  RSS feed

 
Michael Michna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem I can't get fixed from my JSP..
I'm using a password checking routine and then forward the user to the appropriate page..
But it doesn't want to redirect the page to that 1 page I want..
When i check the page trough my browser it works fine tough..
[...]
if (toegang==true){%>
<jsp:forward page="Toevoegen.jsp"/>
<%}
else{%>
<jsp:forward page="GeenToegang.jsp"/>
<%}%>
I can change "Toevoegen.jsp" to whatever I want and it'll work.. except with that page..
Here's the code for "Toevoegen.jsp"
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<HTML>
<HEAD> <TITLE>Voeg een produktje�h toe</TITLE>
<link rel="stylesheet" href="gip.css" type="text/css">
</HEAD>
<BODY>
<P>Voeg een produkt toe
<FORM name="frmToevoegen" action="toevoegen.jsp" method="post">
<TABLE width="50%" border="0" cellspacing="0" cellpadding="0">
<TR>
<TD width="10%">Merk:</TD>
<TD width="90%">
<INPUT type="text" name="MerkIn" size="25">
</TD>
</TR>
<TR>
<TD width="10%">Type:</TD>
<TD width="90%">
<INPUT type="text" name="TypeIn" size="25">
</TD>
</TR>
<TR>
<TD width="10%">Prijs:</TD>
<TD width="90%">
<INPUT type="text" name="PrijsIn" size="12" maxlength="6">
</TD>
</TR>
<TR>
<TD width="10%">Soort:</TD>
<TD width="90%">
<SELECT name="SoortIn">
<OPTION>CPU</OPTION>
<OPTION>MOBO</OPTION>
<OPTION>CDROM</OPTION>
<OPTION>CDR</OPTION>
<OPTION>DVD</OPTION>
<OPTION>HD</OPTION>
</SELECT>
</TD>
</TR>
<TR>
<TD width="10%"> </TD>
<TD width="90%">
<INPUT type="submit" name="SUBMIT" value="Toevoegen">
</TD>
</TR>
</TABLE>
</FORM>
<P> </P>
<HR>
<P> Inhoud Produktendatabase:
<TABLE BORDER=1 CELLPADDING=0 CELLSPACING=0>
<TR> <TD> Merk </TD>
<TD> Type </TD>
<TD> Soort </TD>
<TD> Prijs </TD>
</TR>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc dbc rodukten";
Connection con = DriverManager.getConnection(url);
Statement stmt = con.createStatement();

ResultSet rsMaxNr = stmt.executeQuery("SELECT Max(tblProdukten.Nr) AS MaxVanNr FROM tblProdukten");
int maxNr=0;
while (rsMaxNr.next()) {
maxNr = rsMaxNr.getInt("MaxVanNr") + 1;
// Autonummering uit Tabel halen en + 1

}
rsMaxNr.close();

Enumeration parameters = request.getParameterNames();

String MerkParam;
String TypeParam;
Double PrijsParam;
String SoortParam;
String FotoParam;
String BeschParam;
if(parameters.hasMoreElements()) {
MerkParam = request.getParameter("MerkIn");
TypeParam = request.getParameter("TypeIn");
PrijsParam = new Double(request.getParameter("PrijsIn"));
SoortParam = request.getParameter("SoortIn");
BeschParam ="";
FotoParam = "Gfx\\geenfoto.gif";

stmt.executeUpdate("INSERT INTO tblProdukten VALUES("+maxNr+",'"+MerkParam+"','"+TypeParam+"',"+PrijsParam+", '"+BeschParam+"', '"+SoortParam+"','"+FotoParam+"')");
}

ResultSet rs = stmt.executeQuery("SELECT * FROM tblProdukten ORDER BY MERK");
while(rs.next()) {
String merk = rs.getString("MERK");
String mijntype = rs.getString("TYPE");
String soort = rs.getString("SOORT");
double prijs = rs.getDouble("PRIJS");%>
<TR> <TD> <%= merk %> </TD>
<TD> <%= mijntype %> </TD>
<TD> <%= soort %> </TD>
<TD> <%= prijs %> </TD>
</TR>
<% } %>
</TABLE>
<p> <a href="index.jsp">Index</a>
</BODY>
</HTML>

Any help is greatly appreciated,
Greetings,
Michael Michna
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you have a <% right before your if or is this just a typo?
 
Michael Michna
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes, i have
that part just works fine, it just won't let me redirect the page I want (the second piece of code), I can use it to forward the user to every page I want, except that one.. If I try I get this:
java.lang.NullPointerException
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:986)
at java.lang.Double.valueOf(Double.java:168)
at java.lang.Double.(Double.java:240)
at org.apache.jsp.toevoegen$jsp._jspService(toevoegen$jsp.java:96)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:683)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:431)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:355)
at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:414)
at org.apache.jsp.LogInVerwerking$jsp._jspService(LogInVerwerking$jsp.java:109)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:202)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:190)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1012)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107)
at java.lang.Thread.run(Thread.java:484)
thanks,
Michael Michna
 
Caven Wang
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are Toevoegen.jsp and your login page in the same directory? Check the page path?!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!