Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old July 7th, 2003, 12:39 AM
Chicago_Jae Chicago_Jae is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 73 Chicago_Jae User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 30 m 43 sec
Reputation Power: 6
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.

Reply With Quote
  #2  
Old July 7th, 2003, 09:44 AM
Nemi Nemi is offline
Clueless llama
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Feb 2001
Location: Lincoln, NE. USA
Posts: 2,353 Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level)Nemi User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 2 Days 12 h 35 m 19 sec
Reputation Power: 111
Your question is too vague. Can you post what code you have tried and explain exactly what you are trying to do?

Reply With Quote
  #3  
Old July 7th, 2003, 12:12 PM
Chicago_Jae Chicago_Jae is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Los Angeles
Posts: 73 Chicago_Jae User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 30 m 43 sec
Reputation Power: 6
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

}
%>

Reply With Quote
  #4  
Old July 7th, 2003, 01:29 PM
bricker42 bricker42 is offline
Moderator =(8^(|)
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Feb 2002
Location: Sacramento, CA
Posts: 1,710 bricker42 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 38 sec
Reputation Power: 8
Send a message via AIM to bricker42
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" ); %>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > I just want my JspWriter!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT