Jump to content
xisto Community

welcome77in

Members
  • Content Count

    5
  • Joined

  • Last visited

Everything posted by welcome77in

  1. hi u can use jsp code for making connection between mysql and jsp which need to make connection. 1. Need mysql jdbc connector. Download it from mysql website mysql-connector.jar file 2. Copy it to tomcat or lib folder of WEB-INF in lib folder.This jar file 3. Do little coding to connect it String connectionURL ="jdbc:mysql://localhost:3306/YourDataBaseName?user=root;password="; Connection conn=null; Class.forName("com.mysql.jdbc.Driver").newInstance(); conn = DriverManager.getConnection(connectionURL,"root",""); Statement st=null; st=conn.createStatement(); ResultSet rs= null;Try it
  2. Can anyone give idea about video streaming in web browser through java or jsp I need to play video presentation in my web browser to show all members of the company.For I want to put my video file in web server and anyone can access that video just playing on their browser our web browser is firefox. We donât want to use any active X properties or any default media player in web browser . Our Platform is linux fedora core4, web server is tomcat 5 . We read the JMF java media Framework API, but I couldnât understand how to use this in our server for linux. There is scripts for player in java /* try { JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.writePropArgs); JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.readPropArgs); JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.connectArgs); } catch (Exception e) {} */ // Create an instance of a player for this media try { player = Manager.createPlayer(mrl); } catch (NoPlayerException e) { System.out.println(e); Fatal("Could not create player for " + mrl); } // Add ourselves as a listener for a player's events player.addControllerListener(this); } catch (MalformedURLException e) { Fatal("Invalid media file URL!"); } catch (IOException e) { Fatal("IO exception creating player for " + mrl); } // This applet assumes that its start() calls // player.start(). This causes the player to become // realized. Once realized, the applet will get // the visual and control panel components and add // them to the Applet. These components are not added // during init() because they are long operations that // would make us appear unresposive to the user. } /** * Start media file playback. This function is called the * first time that the Applet runs and every * time the user re-enters the page. */ public void start() { //$ System.out.println("Applet.start() is called"); // Call start() to prefetch and start the player. if (player != null) player.start(); } /** * Stop media file playback and release resource before * leaving the page. */ public void stop() { //$ System.out.println("Applet.stop() is called"); if (player != null) { player.stop(); player.deallocate(); } } public void destroy() { //$ System.out.println("Applet.destroy() is called"); player.close(); } /** * This controllerUpdate function must be defined in order to * implement a ControllerListener interface. This * function will be called whenever there is a media event */ public synchronized void controllerUpdate(ControllerEvent event) { // If we're getting messages from a dead player, // just leave if (player == null) return; // When the player is Realized, get the visual // and control components and add them to the Applet if (event instanceof RealizeCompleteEvent) { if (progressBar != null) { panel.remove(progressBar); progressBar = null; } int width = 320; int height = 0; if (controlComponent == null) if (( controlComponent = player.getControlPanelComponent()) != null) { controlPanelHeight = controlComponent.getPreferredSize().height; panel.add(controlComponent); height += controlPanelHeight; } if (visualComponent == null) if (( visualComponent = player.getVisualComponent())!= null) { panel.add(visualComponent); Dimension videoSize = visualComponent.getPreferredSize(); videoWidth = videoSize.width; videoHeight = videoSize.height; width = videoWidth; height += videoHeight; visualComponent.setBounds(0, 0, videoWidth, videoHeight); } panel.setBounds(0, 0, width, height); if (controlComponent != null) { controlComponent.setBounds(0, videoHeight, width, controlPanelHeight); controlComponent.invalidate(); } } else if (event instanceof CachingControlEvent) { if (player.getState() > Controller.Realizing) return; // Put a progress bar up when downloading starts, // take it down when downloading ends. CachingControlEvent e = (CachingControlEvent) event; CachingControl cc = e.getCachingControl(); // Add the bar if not already there ... if (progressBar == null) { if ((progressBar = cc.getControlComponent()) != null) { panel.add(progressBar); panel.setSize(progressBar.getPreferredSize()); validate(); } } } else if (event instanceof EndOfMediaEvent) { // We've reached the end of the media; rewind and // start over player.setMediaTime(new Time(0)); player.start(); } else if (event instanceof ControllerErrorEvent) { // Tell TypicalPlayerApplet.start() to call it a day player = null; Fatal(((ControllerErrorEvent)event).getMessage()); } else if (event instanceof ControllerClosedEvent) { panel.removeAll(); } } void Fatal (String s) { // Applications will make various choices about what // to do here. We print a message System.err.println("FATAL ERROR linenums:0'>import java.applet.Applet;import java.awt.*;import java.awt.event.*;import java.lang.String;import java.net.URL;import java.net.MalformedURLException;import java.io.IOException;import java.util.Properties;import javax.media.*;//import com.sun.media.util.JMFSecurity;/** * This is a Java Applet that demonstrates how to create a simple * media player with a media event listener. It will play the * media clip right away and continuously loop. * * <!-- Sample HTML * <applet code=SimplePlayerApplet width=320 height=300> * <param name=file value="sun.avi"> * </applet> * --> */public class SimplePlayerApplet extends Applet implements ControllerListener { // media Player Player player = null; // component in which video is playing Component visualComponent = null; // controls gain, position, start, stop Component controlComponent = null; // displays progress during download Component progressBar = null; boolean firstTime = true; long CachingSize = 0L; Panel panel = null; int controlPanelHeight = 0; int videoWidth = 0; int videoHeight = 0; /** * Read the applet file parameter and create the media * player. */ public void init() { //$ System.out.println("Applet.init() is called"); setLayout(null); setBackground(Color.white); panel = new Panel(); panel.setLayout( null ); add(panel); panel.setBounds(0, 0, 320, 240); // input file name from html param String mediaFile = null; // URL for our media file MediaLocator mrl = null; URL url = null; // Get the media filename info. // The applet tag should contain the path to the // source media file, relative to the html page. if ((mediaFile = getParameter("FILE")) == null) Fatal("Invalid media file parameter"); try { url = new URL(getDocumentBase(), mediaFile); mediaFile = url.toExternalForm(); } catch (MalformedURLException mue) { } try { // Create a media locator from the file name if ((mrl = new MediaLocator(mediaFile)) == null) Fatal("Can't build URL for " + mediaFile); /* try { JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.writePropArgs); JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.readPropArgs); JMFSecurity.enablePrivilege.invoke(JMFSecurity.privilegeManager, JMFSecurity.connectArgs); } catch (Exception e) {} */ // Create an instance of a player for this media try { player = Manager.createPlayer(mrl); } catch (NoPlayerException e) { System.out.println(e); Fatal("Could not create player for " + mrl); } // Add ourselves as a listener for a player's events player.addControllerListener(this); } catch (MalformedURLException e) { Fatal("Invalid media file URL!"); } catch (IOException e) { Fatal("IO exception creating player for " + mrl); } // This applet assumes that its start() calls // player.start(). This causes the player to become // realized. Once realized, the applet will get // the visual and control panel components and add // them to the Applet. These components are not added // during init() because they are long operations that // would make us appear unresposive to the user. } /** * Start media file playback. This function is called the * first time that the Applet runs and every * time the user re-enters the page. */ public void start() { //$ System.out.println("Applet.start() is called"); // Call start() to prefetch and start the player. if (player != null) player.start(); } /** * Stop media file playback and release resource before * leaving the page. */ public void stop() { //$ System.out.println("Applet.stop() is called"); if (player != null) { player.stop(); player.deallocate(); } } public void destroy() { //$ System.out.println("Applet.destroy() is called"); player.close(); } /** * This controllerUpdate function must be defined in order to * implement a ControllerListener interface. This * function will be called whenever there is a media event */ public synchronized void controllerUpdate(ControllerEvent event) { // If we're getting messages from a dead player, // just leave if (player == null) return; // When the player is Realized, get the visual // and control components and add them to the Applet if (event instanceof RealizeCompleteEvent) { if (progressBar != null) { panel.remove(progressBar); progressBar = null; } int width = 320; int height = 0; if (controlComponent == null) if (( controlComponent = player.getControlPanelComponent()) != null) { controlPanelHeight = controlComponent.getPreferredSize().height; panel.add(controlComponent); height += controlPanelHeight; } if (visualComponent == null) if (( visualComponent = player.getVisualComponent())!= null) { panel.add(visualComponent); Dimension videoSize = visualComponent.getPreferredSize(); videoWidth = videoSize.width; videoHeight = videoSize.height; width = videoWidth; height += videoHeight; visualComponent.setBounds(0, 0, videoWidth, videoHeight); } panel.setBounds(0, 0, width, height); if (controlComponent != null) { controlComponent.setBounds(0, videoHeight, width, controlPanelHeight); controlComponent.invalidate(); } } else if (event instanceof CachingControlEvent) { if (player.getState() > Controller.Realizing) return; // Put a progress bar up when downloading starts, // take it down when downloading ends. CachingControlEvent e = (CachingControlEvent) event; CachingControl cc = e.getCachingControl(); // Add the bar if not already there ... if (progressBar == null) { if ((progressBar = cc.getControlComponent()) != null) { panel.add(progressBar); panel.setSize(progressBar.getPreferredSize()); validate(); } } } else if (event instanceof EndOfMediaEvent) { // We've reached the end of the media; rewind and // start over player.setMediaTime(new Time(0)); player.start(); } else if (event instanceof ControllerErrorEvent) { // Tell TypicalPlayerApplet.start() to call it a day player = null; Fatal(((ControllerErrorEvent)event).getMessage()); } else if (event instanceof ControllerClosedEvent) { panel.removeAll(); } } void Fatal (String s) { // Applications will make various choices about what // to do here. We print a message System.err.println("FATAL ERROR: " + s); throw new Error(s); // Invoke the uncaught exception // handler System.exit() is another // choice. }} What I am not avail to understand this script Please help me to run video in web browser (firefox ) through video streaming technology. Now currently I am using the flash player and convert avi file to swf file to play in web browser. Which is not good idea Notice from miCRoSCoPiC^eaRthLinG: It's mandatory on our board to enclose large blocks of code within the CODE or CODEBOX tags. Failure to do so, will cause your post credits to be adjusted - which is most cases results in complete deduction of the credits gained for the concerned post. Reducing Hosting credits worth 25 days.
  3. New mysql server doesn’t take blank field through JSP code.If you write this code in jsp it will show error.<%String sqlInsertDateIntoTable = “insert into TableName values( “”, ‘”+request.getParameter(“inputFieldName”)+”’,’”+request.getParameter(“inputFieldName2”)+”’,’’)”;stm.executeUpdate(sqlInsertDateIntoTable);%>This code shows error , But in old alpha version of mysql allow the blank field for autoincreaments.Error shows of “Data truncation“This can be easily remove by just write or add or table values in your querye.g<%String sqlInsertDateIntoTable = “insert into TableName (Name,Address) values(‘”+request.getParameter(“inputFieldName”)+”’,’”+request.getParameter(“inputFieldName2”)+”’)”;stm.executeUpdate(sqlInsertDateIntoTable);%>This code will save u from data trancation error and allow empty or default value of table in Mysql serverAutoincreament done automatically by Mysql and other blank field automatically taken default value given in the table.
  4. I have to upload images from client side to server side, without using input tag or browseing of file. I know the absolute path of file in client side. And that file I want to shift to server with JSP code or any servlet code. I have done uploading through servlet to the server with input tag and type is file . Servlet code : import com.oreilly.servlet.MultipartRequest;import java.io.*;import java.util.*;import javax.servlet.*;import javax.servlet.http.*;public class UploadPhoto extends HttpServlet {public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException , IOException {res.setContentType("text/html");PrintWriter out = res.getWriter();String rtempfile = File.createTempFile("temp","1").getParent();MultipartRequest multi = new MultipartRequest(req, rtempfile, 500 * 1024); File rnewfile=null;rnewfile = new File(new File("/").getAbsolutePath()+File.separator+"tomcat"+File.separator+"webapps"+File.separator+"ROOT"+File.separator+"Photo"+File.separator+"YourPhotoname.jpg");out.println("<HTML>");out.println("<head><title>UPLOAD PHOTO</title></head>");out.println("<body>");out.println("<Pre>");Enumeration files = multi.getFileNames();while (files.hasMoreElements()) {File f = multi.getFile(name);FileInputStream fin =new FileInputStream(f);ImageInfo ii =new ImageInfo();ii.setInput(fin);fin.close(); fin =new FileInputStream(f); FileOutPutStream fos =new FileOutPutStream(rnewfile); byte sizefile[] = new byte[500000]; fin.read(sizefile); fin.write(sizefile); fos.close(); fin.close();f.delete();}res.sendRedirect("Your.jsp");}} This code needs oreilly Image package API Can anyone help me to upload to file without using <form method=post type =encrpted> <input type=âfileâ name= âuploadfileâ> if I use <input type=âfileâ name= âuploadfileâ value=âc:\temp\myphoto.jpgâ> it doesnât work.. Notice from moonwitch: We require you to pour large chunks of code into the code tags. Reduced Credits by 6 days
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.