eric clark

Greenhorn
+ Follow
since Jan 18, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by eric clark

hithere, just in case any1 knows. i have a servlet that writes a jpg from a text and a background rectangle, using graphics2d. when the x11 server runs, it werx fine, but when its not running, it makes some weird errors. the weird thing is, that theres no connection to x11. and i dont need the graphical enviroment, i only wanna genaret a jpg.
error:
javax.servlet.ServletException: sun/awt/X11GraphicsEnvironment
servlet source:
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.awt.*;
import java.awt.Image;
import java.awt.Graphics2D;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageEncoder;
import java.awt.geom.Rectangle2D;
public class JPEGServlet {

public void generateButton()
{
// Create image
int width = 400; // width of image
int height = 200; // height of image
BufferedImage image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB); // Image object to paint with
Graphics2D g = image.createGraphics(); // Get graphics context
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias the painting
// First set background color to white by painting a filled rectangle
g.setPaint(Color.white);
Rectangle2D rectangle = new Rectangle2D.Double(0, 0, width, height);
g.fill(rectangle);
GradientPaint gp = new GradientPaint(
0, 0, Color.lightGray,
400, 100, Color.black); // Create a gradient fill from lightgray to black
g.setPaint(gp); // Use gradient fill to draw text
g.setFont(new Font("Serif", Font.BOLD, 40)); // Set font bold and size 40
g.drawString("Hello!", 0, 30);
// JPEG-encode the image
//and write to file.
try
{
System.out.println("writing file");
OutputStream os =
new FileOutputStream("bla.jpg");
JPEGImageEncoder encoder =
JPEGCodec.createJPEGEncoder(os);
encoder.encode(image);
os.close();
}
catch (Exception e)
{
}
}
}

24 years ago
thanx, managed it btw, with getting some sql book
grtx eric
24 years ago
hithere! im just searching a way to map some text, the user inputs on a pic and how to safe the whole as some jpg after...any1 could help? didnt find something in this way somewhere....
thx
eric
24 years ago
hithere. just stuck on some jsp/sql coding. i did a database with pictures. and a jsp form with 5 fields, where 1 has to be filled, 5 can be filled, now i wanna search the db with criterias from the fields. some1 could explain me how this works?
im also stuck on the sql for this..
thx eric
24 years ago
hi all, i just wrote something to read all files in a specific dir.works fine. now i made something where the user can create new sub-dirs in this dir.werks,2.so when i readout the main dir, the reading routine shows me the subdirs as files,2. now i need to differ if its a file or a new dir, and when i click it (the subdir), i need to see the files in the subdir. how can i differ between files and directory names then? plz help, its urgent. thx
eric
24 years ago
prolly ya could create a temp file and use it to determine your absolute path and delete it after?
String tempName = "foo";
File temp = new File(tempName);
temp.createNewFile();
String path = temp.getAbsolutePath();
String path = path.substring(0, path.indexof(tempName));
something this way should werk, grtx
eric
[This message has been edited by eric clark (edited February 14, 2001).]
24 years ago
heya im searching a way, how a servlet could recalculate a tiff picture lets say from 300dpi into 72 dpi and safe it as a jpeg after. any1 ideas? thx eric
24 years ago
hithere, im just wondering, how i can calculate a new size of some image with the help of jsp/java and how i can recalculate its resolution, lets say it is a 300dpi tiff and i wanna recalculate it into 72dpis
thx eric
24 years ago
hithere! i got to do something, that reads a path of images, when one is clicked, a thumbnail is shown. then i got the possibility to render the prefered image lets say from 300 to 72 dpi or change its size..as i dunno where to start, id be glad, if some1 would have some urls that cope with this topic or some other hints...id prefer to use as much jsp as possible, without the use of beans or servlets. thx+ greets eric
24 years ago
hithere! lemme try to explain ma newest problem. im werking on a content composing system, written in java, jsp.(although im a newbie :/). atm im about to do a module, where the user can built a site navigation (text-links only). so he has some form, where he inputs the main navigation points. those are written in a database. if hes done, he can make sub-menu items for each main item etc, and it should be in a way, where every menu-item can have endless sub-menus etc. so im stuck about how i should do this. some1 told me bout recursive programming, but as i said im a newbie. so prolly som1 could drive me into the right way, how to do this or has done something similar? cheers eric
24 years ago
to get the values if buttons are selected or not, ya simply could do the following, that werked for me:
String paraname = "";
for (Enumeration selectedValues = request.getParameterNames();selectedValues.hasMoreElements(); ) {
paraname = selectedValues.nextElement().toString();
cheers
eric
24 years ago
i wanna access some button instance and test if x and y values do not exist, so i tried the following:
if( (paraname != "x" ) && ( paraname != "y") )
now it seems that they cant be accessed this way, some1 knows?
thx eric
24 years ago
thanx, it works now
greets eric
24 years ago
im trying to read in a properties file, this werks like this:
Properties pr = new Properties();
File fname = new File("/tmp/deprop.properties");
FileInputStream input_stream = new FileInputStream(fname);
pr.load(input_stream);
String Name = pr.getProperty("Name");
now i wanna built a loop to readin all existing record and automatically built the strings out of it , like
properties file: name = eric jsp-page: string name = pr.getprop("name"), etc some1 could help me plz?
what i need to know,2 how do i write a properties file, is it the same way then reading it? thx
eric
[This message has been edited by eric clark (edited January 19, 2001).]
24 years ago
mornin all, im just trying to find some way to collect all data from a field of radiobuttons on a jsp site, to write it back in a database..what i got btw is this:
String paraname = "";
for (Enumeration selectedValues = request.getParameterNames();selectedValues.hasMoreElements(); ) {
paraname = selectedValues.nextElement().toString();
out.print("|"+paraname+"|");
out.println(request.getParameterValues(paraname));
}
problem is that it doesnt werk prolly some1 sees a solution?
[This message has been edited by eric clark (edited January 18, 2001).]
24 years ago