<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<% 
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;



public class Validation

{
	public Validation()
    {
	
    	System.err.println("nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn");
        
    }
        
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Subittion Page</title>


</head>
<body>
Your rquest has been processed.
</body>
</html>

can someone test this code in JSP because it keeps giving me errors when i run it in tomcat

Recommended Answers

All 17 Replies

I have no idea what you trying to achieve with above code, but that is one hell of example on inappropriate use of JSP.
Putting servlet logic into JSP OUCHHHHHHH

I have no idea what you trying to achieve with above code, but that is one hell of example on inappropriate use of JSP.
Putting servlet logic into JSP OUCHHHHHHH

all i want to know is if the code functions or not, ie displays the error message.
and forget the servlet, its just there for the sake of being there

No it does not work!

No it does not work!

so how can i make it display an error message saying anything is JSP?

and how do i import java. anything

so how can i make it display an error message saying anything is JSP?

More precise description of the problem would be nice

More precise description of the problem would be nice

<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<% import java.io.*;
import java.util.*;


public class Validation

{
	public Validation()
    {
    try
        {
    String name = request.getParameter("name");
    String emailadd = request.getParameter("emailadd");
    int studentno1 = request.getParameter("studentno1");
    int studentno2 = request.getParameter("studentno2");
    	        	if (name.length >= 3 && studentno1.length = 8 && studentno1 = studentno2)
	            {
    	        	<ct:mail to= emailadd>
					Student Name: <%=request.getParameter("name")%>
                    Student Number: <%=request.getParameter(""+"studentno1")%>
                    </ct:mail>
                    <ct:mail to="info@scocietybrton.co.uk">

                    E-mail Address: <%=request.getParameter("email"%>
					Student Name: <%=request.getParameter("name")%>
                    Student Number: <%=request.getParameter(""+"studentno1")%>

                    </ct:mail>
        	    }
                else
                {
                	System.err.println("data inputed is incorrect.");
                }
        }
        catch 
        {
        	System.err.println("data inputed is incorrect.");
        }
    }
        
}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Subittion Page</title>


</head>
<body>
Your rquest has been processed.
</body>
</html>

it is supposed to process the parameters entered in a previous page, and validate them, if they are incorrect it sends an error message. a web developer and a friend of mine told me it looks sound as a JSP but he cant debug, which is what i need, if the parameters are correct it opens 2 mailto links

Just do not tell me this is a school project and your teacher specifically told you to only use JSP and not servlets. Seriously I'm on the edge to explode on all these silly teachers demands that I seen in recent days in JSP section.
Reason is simple page1 send validation to servlet. Servlet does the validation and decide if to return back to page 1 or or go forward to page2 as validation was correct.

Just do not tell me this is a school project and your teacher specifically told you to only use JSP and not servlets. Seriously I'm on the edge to explode on all these silly teachers demands that I seen in recent days in JSP section.
Reason is simple page1 send validation to servlet. Servlet does the validation and decide if to return back to page 1 or or go forward to page2 as validation was correct.

its university and well i just wanna make sure the syntax is correct, and i know its stupid but ill repeat the year without this

Then do it in correct way. Split the above code on servlet(the validation section) and JSP page (the html bit). Do you actually have installed Tomcat server with appropriate libraries?

Then do it in correct way. Split the above code on servlet(the validation section) and JSP page (the html bit). Do you actually have installed Tomcat server with appropriate libraries?

yeh did but it wont run anything with functions or import, and i even tried web tutorials that are garenteed 100% and they did not work thats were my problem is

Did you used correct directory layout?

yeah andi i just added something the "" around the imported "java.------"

If you did use correct directory layout then what are the errors reported by Tomcat?

If you did use correct directory layout then what are the errors reported by Tomcat?

yah its saying the import token does not exist

Please post the exact message

that is the exact message

but anyway is there something wrong with the code???
the import java.util*;
was changed to
import "java.util*";

import java.util.*;
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.