Results 1 to 2 of 2
- 02-23-2010, 09:06 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 1
- Rep Power
- 0
How to use and print the JAVA code from a JSP
hi all, im new to JSP, i want to write a JSP that can read the exif infomation from JPEG,
1)how can i use the $path in <%!
2)how can i print the data from <%!
thank U & sorry for my poor english!
script︰
Java Code:<%@ page language="java" contentType="text/html; charset=big5" import="java.util.*, java.io.*"%> <%@ page import="com.drew.metadata.*"%> <%@ page import="com.drew.metadata.exif.*"%> <%@ page import="com.drew.imaging.jpeg.JpegProcessingException"%> <% Date $date= new Date(); String $patha=new File(application.getRealPath("/")).getParent(); String $pathb=new File(request.getRequestURI()).getParent(); String $path=$patha+$pathb+"\\"; %> <!-- client comment, time: <%=$date%> --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=big5"> <title>JSP Try - 05_exif</title> </head> <body> <%! public static void main(String args[]) throws FileNotFoundException { [color=red][b]File f = new File("X:/xxx/xxx.JPG");[/b] /*1)Can i change to the following line︰ [b]File f = new File($path +"xxx.JPG");*/[/b][/color] try { ExifReader er = new ExifReaderRose; Metadata exif = er.extract(); Iterator itr = exif.getDirectoryIterator(); while (itr.hasNext()) { Directory directory = (Directory) itr.next(); [color=red] /*2)How to print the following lines︰*/ System.out.println("EXIF版本:" + directory.getString(ExifDirectory.TAG_EXIF_VERSION)); System.out.println(" 相機品牌:" + directory.getString(ExifDirectory.TAG_MAKE)); System.out.println(" 像機號碼:" + directory.getString(ExifDirectory.TAG_MODEL)); System.out.println(" 光圈值:" + directory.getString(ExifDirectory.TAG_FNUMBER)); System.out.println(" 快門:" + directory.getString(ExifDirectory.TAG_EXPOSURE_TIME)); System.out.println(" 感光度:" + directory.getString(ExifDirectory.TAG_ISO_EQUIVALENT)); System.out.println(" 軟件:" + directory.getString(ExifDirectory.TAG_SOFTWARE)); System.out.println(" 原始拍攝時間:" + directory.getString(ExifDirectory.TAG_DATETIME_ORIGINAL)); System.out.println(" 數字化時間:" + directory.getString(ExifDirectory.TAG_DATETIME_DIGITIZED)); System.out.println(" 方向:" + directory.getString(ExifDirectory.TAG_ORIENTATION)); System.out.println(" 圖片寬度:" + directory.getString(ExifDirectory.TAG_EXIF_IMAGE_WIDTH)); System.out.println(" 圖片高度:" + directory.getString(ExifDirectory.TAG_EXIF_IMAGE_HEIGHT)); System.out.println(" 水平分辨率:" + directory.getString(ExifDirectory.TAG_X_RESOLUTION)); System.out.println(" 垂直分辨率:" + directory.getString(ExifDirectory.TAG_Y_RESOLUTION)); System.out.println(" 垂直分辨率:" + directory.getString(ExifDirectory.TAG_EXPOSURE_BIAS)); [/color] break; } } catch (JpegProcessingException e) { System.err.println("This is not a JPEG - 這不是JPEG檔"); } } %> </body> </html>
- 02-23-2010, 02:05 PM #2
Senior Member
- Join Date
- Dec 2009
- Location
- Belgrade, Serbia
- Posts
- 364
- Rep Power
- 4
Do you know what are JSP Implicit Objects?
Try this scriptlet in your JSP:
"Out: denotes the Output stream in the context of page. The class or the interface name of the Out object is jsp.JspWriter. The Out object is written: Javax.servlet.jsp.JspWriter"Java Code:<% out.print("Hello World"); %>
They end up visible in the browser requesting the JSP page, not in
java console as System.out.println(...)
TIP:
Writing code in scriptlets is bad habit. Use tags instead.
Similar Threads
-
The code isnt working unless I add print statements at diffrent points!:confused:
By Addez in forum New To JavaReplies: 6Last Post: 11-12-2009, 10:50 AM -
ArrayLists do not print to the terminal window, why? long code inside
By caps_lock in forum New To JavaReplies: 5Last Post: 05-25-2009, 09:03 PM -
Java code to connect printer to print content
By wendyz in forum Advanced JavaReplies: 3Last Post: 04-30-2009, 06:51 PM -
Print the text file and print preview them
By Java Tip in forum java.awtReplies: 0Last Post: 06-22-2008, 11:04 PM -
How to Print out adiamond pattern I try this code but
By masaka in forum New To JavaReplies: 11Last Post: 04-16-2008, 01:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks