|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I just want my JspWriter!!
I am just wondering how I can use the JspWriter object "out" when I'm outside its default scope. I have tried to declare it as,
JspWriter out = null; This does compile, but it gives me a null pointer during runtime. Is there an alternate, easier way to gain access to the writer? I've already tried several ways. |
|
#2
|
|||
|
|||
|
Your question is too vague. Can you post what code you have tried and explain exactly what you are trying to do?
|
|
#3
|
|||
|
|||
|
My question is how can I make the JspWriter "out" work as a global variable? Refer to code below.
--------------------------------------------------------------- <%@page contentType="text/html"%> <%@ page import="java.util.*, java.sql.*, java.io.*, javax.servlet.jsp.*"%> <html> <head><title>Search | CRT</title></head> <body> <% //JSP WRITER WORKS INSIDE THIS SCOPE. String url = "jdbc:mysql:///db"; Class.forName("org.gjt.mm.mysql.Driver"); Connection con = DriverManager.getConnection(url, "", ""); Statement stmt = con.createStatement(); String brand = request.getParameter("brand"); String size = request.getParameter("size"); out.println(brand); %> <%! public void results(String insertString, Statement stmt) throws IOException, SQLException { // I WANT JSPWRITER TO WORK INSIDE THIS SCOPE AS WELL. out.println("<TABLE border = 1>");//obviously a compiler error } %> |
|
#4
|
|||
|
|||
|
Well, you can either pass it to your function as an argument, or you can do something like:
Code:
<%! JspWriter newOut = null; %> <% newOut = out; %> <%! newOut.println( "foo" ); %> |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > I just want my JspWriter!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|