chandu1987 Posted November 9, 2012 Report Posted November 9, 2012 poni "class.getresource" try cheyyi
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [quote name='Thingarodu' timestamp='1352434185' post='1302767613'] asalu mee code lo servlets vunnaya??? oka vela vunte nuvvu create chesina servlet ni instantiate chesi, aa instantiate chesina servlet object nunchi "getServletContext()" method call cheyyi.... [/quote] yeah servlets unnayi..
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [color=#000000][font=Arial,]But if the class is by itself not a [/font][/color]HttpServlet[color=#000000][font=Arial,] at all, then you'd really need to move the properties file into the classpath.[/font][/color] [color=#000000][font=Arial,]na situation idi?[/font][/color] [color=#000000][font=Arial,]idhi solution la dorikindhi.. idhi chesthunna ravatledhu?[/font][/color]
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [quote name='chandu1987' timestamp='1352434188' post='1302767614'] poni "class.getresource" try cheyyi [/quote] [color=#000000][font=Consolas, Menlo, Monaco,]prop.load(getClass().[/font][/color]prop.load(getClass().getResourceAsStream("sample.properties"));[color=#000000][font=Consolas, Menlo, Monaco,]("sample.properties"));[/font][/color] [color=#000000][font=Consolas, Menlo, Monaco,][background=rgb(238, 238, 238)]idhi kuda try chesa.. I tried giving relative path too but not working [/background][/font][/color]
MUSHTODU Posted November 9, 2012 Report Posted November 9, 2012 anna neenu nee fan ni [img]http://www.andhrafriends.com/uploads/profile/photo-thumb-33867.jpg?_r=1352424972[/img]
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [quote name='MUSHTODU' timestamp='1352434796' post='1302767636'] anna neenu nee fan ni [img]http://www.andhrafriends.com/uploads/profile/photo-thumb-33867.jpg?_r=1352424972[/img] [/quote]
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [quote name='GatisKandis' timestamp='1352434993' post='1302767649'] LTT help.. [/quote] tq ne id
Thingarodu Posted November 9, 2012 Report Posted November 9, 2012 oka sari idi try cheyyi... I think this should work for you ResourceBundle rb = ResourceBundle.getBundle( "com.test.sample"); [color=#ff0000]Properties file should be in the "com.test" package with name as "sample.properties".[/color] then you can get the values from properties using rb.getString( "name" )
chandu1987 Posted November 9, 2012 Report Posted November 9, 2012 [quote name='Hava5' timestamp='1352434536' post='1302767630'] [color=#000000][font=Consolas, Menlo, Monaco,]prop.load(getClass().[/font][/color]prop.load(getClass().getResourceAsStream("sample.properties"));[color=#000000][font=Consolas, Menlo, Monaco,]("sample.properties"));[/font][/color] [color=#000000][font=Consolas, Menlo, Monaco,][background=rgb(238, 238, 238)]idhi kuda try chesa.. I tried giving relative path too but not working [/background][/font][/color] [/quote] endhku work cheyyatla...i mean em error vastundhi...try print the path and then add your properties file to that path and try again... For Eg this is what I used in my class: [CODE] Class<ExampleClass> clazz = ExampleClass.class; InputStream inputStream = clazz .getResourceAsStream("/WEB-INF/resources/examplefolder/" + imageName); [/CODE] here clazz .getResourceAsStream is giving the classpath location which is just before the WEB-INF folder, so I have added the image location which is relative to the classpath location given by that method
deals2buy Posted November 9, 2012 Report Posted November 9, 2012 [quote name='MUSHTODU' timestamp='1352434796' post='1302767636'] anna neenu nee fan ni [img]http://www.andhrafriends.com/uploads/profile/photo-thumb-33867.jpg?_r=1352424972[/img] [/quote] [img]http://i56.tinypic.com/2w2r5gm.jpg[/img]
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 com/hava5/servletexample/user.properties ah? com.hava5.servletexample.user.properties ah?
Thingarodu Posted November 9, 2012 Report Posted November 9, 2012 [quote name='Hava5' timestamp='1352435427' post='1302767669'] com/hava5/servletexample/user.properties ah? com.hava5.servletexample.user.properties ah? [/quote] [color=#282828][font=helvetica, arial, sans-serif]ResourceBundle rb = ResourceBundle.getBundle( "[/font][/color]com.hava5.servletexample.user[color=#282828][font=helvetica, arial, sans-serif]");[/font][/color]
ChampakDas Posted November 9, 2012 Report Posted November 9, 2012 changed [quote name='Hava5' timestamp='1352435120' post='1302767653'] tq ne id [/quote]
chinni005 Posted November 9, 2012 Author Report Posted November 9, 2012 [quote name='chandu1987' timestamp='1352435272' post='1302767662'] endhku work cheyyatla...i mean em error vastundhi...try print the path and then add your properties file to that path and try again... For Eg this is what I used in my class: [CODE] Class<ExampleClass> clazz = ExampleClass.class; InputStream inputStream = clazz .getResourceAsStream("/WEB-INF/resources/examplefolder/" + imageName); [/CODE] here clazz .getResourceAsStream is giving the classpath location which is just before the WEB-INF folder, so I have added the image location which is relative to the classpath location given by that method [/quote] Null pointer Exception osthundhi bro.. servlet class run ayeppudu.. ee properties loading line daggara severe Exception ani ento chupisthundhi
Recommended Posts