• Post Reply Bookmark Topic Watch Topic
  • New Topic

The server encountered an internal error  RSS feed

 
arun accent
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please help,
i am a newbie and was doing my first jsp and encountered the following error.
The server encountered an internal error () that prevented it from fulfilling this request.
it cannot resolve the symbols like request in request.getParameter..
can somebody please help.Thank you.
[ August 20, 2005: Message edited by: Bear Bibeault ]
 
Jesus Angeles
Ranch Hand
Posts: 2070
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i think what you supplied is not enough for us to help you. can you provide more info? if the jsp is small enough maybe you can post here the jsp code. or the error message.
 
arun accent
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<html>
<body>
<%@ page import="java.sql.*" %>
<% Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


Connection con=DriverManager.getConnection("jdbc dbc:StudDSN","","");
PreparedStatement ps=con.prepareStatement("insert into

student(Name,Age,Address,Sex,MarkScored,TotalMarks,Password) values(?,?,?,?,?,?,?)");

catch(Exception e) { e.printStackTrace(); }
String name=request.getParameter("name")
ps.setString(1,name);
ps.setInt(2,request.getParameter("age"));
ps.setString(3,request.getParameter("address"));
ps.setString(4,request.getParameter("sex"));
ps.setInt(5,request.getParameter("marksscored"));
ps.setInt(6,request.getParameter("totalmarks"));
ps.setString(7,request.getParameter("password"));
%>
<%=request.getParameter("totalmarks")%>
<%!int a=request.getParameter("marksscored");%>
<%!int total=request.getParameter("totalmarks");%>

<html>
<body>
</body>
</html>
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's the problem:


The <%! tag creates code outside of your service method.
You can only access the implicit objects (request, response, etc..) from within the service method.

Further, any variables declared this way are called "instance variables" and are not thread safe.


please ignore the second html & body tags inthe end...

You can always go back and edit your posts by clicking on the notepad & Pencil icon just over the text.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PS: The best thing a beginning JSP developer can do for him/herself is to find a book or tutorial on Servlets. A lot of the structure of the underlying servlet is abstracted and obfuscated within JSPs.
In a servlet, the structure is clear as day.
After learning servlets, it's a lot easier to figure out what's really happening in a JSP.

This is one of the reasons that keep recommending "Core Servlets and Java Server Pages" It teaches all of these technologies in the correct order.
http://pdf.coreservlets.com
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!