Php to jsp
Hi,
i'am beginning of java programming...
I need help plz to convert this part of PHP code to JSP code :
$fp = fopen("../commun/param".$param.".txt", 'r');
while ($str=fgets($fp,4096)) eval( "".$str.";" );
fclose($fp);Thks
The best way to do so is take php syntax find a way to do it in jsp and recode it
Similar Messages
-
For work I need to convert a code that I wrote in PHP to JSP in order for it to run on our windows server.
Trouble is, I know very little java. The script is a very simple, short email script located here: http://pastebin.com/m7b4b4e96
Any help would be greatly appreciated.Perhaps this one?
http://www.amazon.com/Murachs-Java-Servlets-Andrea-Ste
elman/dp/1890774189/ref=pd_sim_b_5_img/002-0859111-900
5647I have read many many JSP and Servlet books in the past and the book you mentioned (Murachs-Java-Servlets book by Andrea Steelman) is the best by far above any other books. -
Hello,
can I upload and run on apex.oracle.com my own php or jsp scripts ?
Thank youNo.
-
String manipulation: php to jsp
Im converting a menu generation program from PHP to JSP.
Every page in my site has been allocated a page Id.
A pages pageId determines how the primary navigation of the page displays.
My Question
I need to determine the sub Menu parent id To do this in php I can just take the int value of the pageId string to get 2
<?php
$pageId = "2.1.3.4";
$subMenuParentId = intval($pageId);
?>
how can I do this in JSP ? Is there a better solution.
<%
String pageId = "2.1.3.4";
%>You might find this test program novel...
import java.text.*;
public class msgfmttest
public static void main(String[] args)
MessageFormat msgfmt = new MessageFormat("{0,number,integer}.{1,number,integer}.{2,number,integer}.{3,number,integer}");
String pageId = "2.1.3.4";
try {
Object[] levels = msgfmt.parse( pageId );
int level1 = ( (Long)levels[0] ).intValue();
int level2 = ( (Long)levels[1] ).intValue();
int level3 = ( (Long)levels[2] ).intValue();
int level4 = ( (Long)levels[3] ).intValue();
System.out.println("level 1: " + level1);
System.out.println("level 2: " + level2);
System.out.println("level 3: " + level3);
System.out.println("level 4: " + level4);
catch(ParseException exc) {
System.err.println("pageId is invalid");
} -
From PHP to JSP for a search-responder.php
I have been asked to use the "search-as-you-type" solution offered up by Google at [http://code.google.com/p/search-as-you-type/|http://code.google.com/p/search-as-you-type/]. The documentation offered by Google is pretty much straight forward but of course the actual piece of code that gets the data is built in PHP and my client needs this to be used on a page serving up JSP.
I am learning JSP and moving from PHP and ASP and learning quickly but not quick enough to finish the project.
Would anyone be able and willing to help me convert the functions in the following PHP code into JSP?
Thanks in advance to anyone who takes the time to help me.
<?php
* Copyright (C) 2006 Google Inc.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* Search-as-you-type sample Ajax responder
// Adding a cache control so that browsers won't cache Ajax requests
header("Cache-Control: no-cache");
header("Content-Type: text/html; charset=UTF-8");
* Get the sample data from the text file.
* @return array Loaded data
function GetData() {
$data = array();
$file = file("test-data.txt");
foreach($file as $record) {
$record = explode("|", trim($record));
if (count($record) == 4) { // Ignore invalid lines
$data[] = $record;
return $data;
* Get the results based on user's query.
* @param string $query Query
* @param array $data Sample data
* @return array Result array
function GetResults($query, $data) {
$results = array();
$queryLength = strlen($query);
foreach ($data as $record) {
if (substr(strtolower($record[0]), 0, $queryLength) == $query) {
$result = array();
$result['name'] = $record[0];
$result['type'] = $record[1];
$result['content'] = $record[2];
$result['moreDetailsUrl'] = $record[3];
$result['style'] =
($query == strtolower($record[0])) ? 'expanded' : 'normal';
$results[] = $result;
return $results;
// Get the data and the query
$data = GetData();
$query = strtolower(ltrim($_GET['query']));
// Build response
$response = array();
$response['query'] = $query;
$response['results'] = GetResults($query, $data);
if (count($response['results']) == 1) {
$response['autocompletedQuery'] = $response['results'][0]['name'];
// Output response
echo "searchAsYouType.handleAjaxResponse(";
echo json_encode($response);
echo ");";
?>Thanks for your comment Gimbal2.
I have already been thoroughly surprised at how different JSP is from PHP. I am finding quite hard to wrap my head around the whole process to be honest.
I am beginning to see that JSP and PHP work in a totally different way than each other.
I am not technically trying to translate or convert the PHP file as much as I am trying to build a file in JSP that does the same functions. The main functions of the PHP script are commented by Google and should be easily enough re-written in JSP in order to produce similar results.
Since the output needs to be in a JSON format when passed to the .js file you'd think this would be better suited as a .jsp file as well or even a JAVA Applet, Servlet or even a bean. Since the whole site is already built in JSP for a multitude of other functions it seems likely that adding on more to read data from a source file and send it back to the .JS would be straight forward, but I could be wrong. But again I am not familiar enough with JAVA or JSP (yet) to make heads or tails of this.
1. // Adding a cache control so that browsers won't cache Ajax requests
2. * Get the sample data from the text file. @return array Loaded data
3. * Get the results based on user's query.
* @param string $query Query
* @param array $data Sample data
* @return array Result array
4. // Get the data and the query
5. // Build response
6. // Output response -
Hi all,
I have a problem. We have a portal (weblogic) and we want to integrate into portal
sites that developed in php. Is this possible?
Thank you
TamasJSP without java is a bit like PHP without html
...only worse.Which is why I'm looking for a book or onlinetutorial
which teaches Java with a focus on JSP.Well that's nice ...but YOU were the one who asked for
advice from people who you may assume to know more
than you do. Take it or leave it, makes bugger all
dif'rence to me ... erm, learn java first.I want to learn Java, but I don't have much use for it outside of JSP. Aren't there any books which teach Java, but in the context of web development? -
Hola.
Quisiera saber si alguno sabe como hacer una insercion en una
pagina php a
dos tablas diferentes en un mismo formulario (en Dreamweaver
MX), ya tengo
la pagina php pero solo me inserta a una table necesito que
los datos de
algunos campos lo haga en otra tabla pero que el usuario solo
de una sola
vez en el boton registrar, muchas gracias por la ayuda que me
puedan
brindar.
cordial saludo
HaroldHola.
Quisiera saber si alguno sabe como hacer una insercion en una
pagina php a
dos tablas diferentes en un mismo formulario (en Dreamweaver
MX), ya tengo
la pagina php pero solo me inserta a una table necesito que
los datos de
algunos campos lo haga en otra tabla pero que el usuario solo
de una sola
vez en el boton registrar, muchas gracias por la ayuda que me
puedan
brindar.
cordial saludo
Harold -
Is it possible (with calculable effort) to integrate JSPs in a PHP driven web site? Or are Java experts kicked off that way?
Hmm, this is becoming a little tougher. You can't really mix PHP and JSP code in the exact same file, because your webserver would send it off to either the JVM or the PHP interpreter and both are going to fail when reading the 'alien' code.
I think you could use include tags in a JSP to place the PHP parts where you'd like to have them. I believe the PHP would be parsed before it is given to the JVM and then the result, which is common HTML, is inserted into the JSP page. That way you wouldn't need to rewrite any of the portions that are already available in PHP.
Check out http://java.sun.com/webservices/docs/1.0/tutorial/doc/JSPIntro8.html for detailed information on including stuff in JSP pages... -
WebLogic JSP Accelerator for Dreamweaver MX
Here's a freeby extension for those of you who use Dreamweaver MX to edit JSP...
Weblogic Portal JSP Accelerator
A Macromedia Dreamweaver MX Extension
This custom extension allows you to accelerate your development time with BEA's
WebLogic portal 7.0 by providing taglib inserts and code completion for the entire
WebLogic 7.0 JSP API in Macromedia Dreamweaver MX.
Get it at http://www.quantumj.comThe real questions are a) does valid code matter to you, b)
will you be
using CSS, and c) do you work mostly in Design view?
If the answer to any of those is "YES", then you should
upgrade.
Murray --- ICQ 71997575
Adobe Community Expert
(If you *MUST* email me, don't LAUGH when you do so!)
==================
http://www.projectseven.com/go
- DW FAQs, Tutorials & Resources
http://www.dwfaq.com - DW FAQs,
Tutorials & Resources
==================
"SimpBit" <[email protected]> wrote in
message
news:g35hjr$ie7$[email protected]..
>A few years ago i used Dreamweaver mx for creating
websites. In the
>meantime
> i?ve graduated ad software developer and now?s the time
for a hobby.
>
> So whats the difference between dreamweaver mx and
dreamweaver cs.??
>
> I?ll be using php, asp, jsp, mysql.
> -
Structuring a JSP/J2EE (Tomcat) application
If anyone can give some direction on this, then I'd be very happy.
I am trying to rewrite an application I previously developed in PHP using JSP/J2EE in a Tomcat enviroment. I am rather unsure about how the application and related files should be organised. For instance, should my "own" application-related configuration files (whatever.xml) be stored in the WEB-INF directory? Also, should application-specific log files be stored somewhere in the application structure, or would those typically be located where the server logs are? For application-specific logging, should I use java.util.Logging or something like log4j?
I will be using three different environments (dev, staging and production) for this, and would ideally like to make the application easily configurable to move it between these environments.
Sincerely,
Nils Hagnerhagner wrote:
If anyone can give some direction on this, then I'd be very happy.
I am trying to rewrite an application I previously developed in PHP using JSP/J2EE in a Tomcat enviroment. I am rather unsure about how the application and related files should be organised. For instance, should my "own" application-related configuration files (whatever.xml) be stored in the WEB-INF directory? Also, should application-specific log files be stored somewhere in the application structure, or would those typically be located where the server logs are? For application-specific logging, should I use java.util.Logging or something like log4j?
I will be using three different environments (dev, staging and production) for this, and would ideally like to make the application easily configurable to move it between these environments.Usually you put your own configuration files in the /WEB-INF/classes directory because then they will be in the classloader's classpath.
Log files go in the same log directory as the server logs (in tomcat this is just ${CATALINA_HOME}/logs/)
You can use either the java logging or log4j that is up to you (I think log4j is better personally because it has more features) -
Why doesnt jsp:include work?
Hello all
I am trying to include a header file in my jsp page, and then include a servlet on another server. Question is, is this possible? In my code below, the header file is shown but the results of the servlet, which resides on a different server, are not. Any idea why the second line doesnt work?
Thanks in advance for any help.
<%@ include file="header.jsp" %>
<jsp:include page="http://differentserver:1080/servlet/Docu?dir=AdminProc" flush="true" />Thanks for the clarification. I am actually trying to convert some PHP to JSP, and idea what the equivalent of
<?php
include("header.php");
include("http://differentserver:1080/servlet/DocuServ?dir=Procedures");
?>
is in JSP? -
Gidday All,
I am converting an application from PHP to JSP
in PHP I am able to explode a strings parts into an array.
For example
my string = "1.21.32.45.232";
I want jsp to return an array containing the parts of this string separated by dots into an array.
Any help appreciated.
Thank You
ColinThanks everyone for your help,
I knocked this up but don't get any output?
Any help appreciated.
Thank You
Colin
<html>
<head>
</head>
<%@ page language="java" import="java.util.StringTokenizer" %>
<body>
<%
StringTokenizer st = new StringTokenizer("123.21.56.23", ".");
while ( st.hasMoreTokens() ){
System.out.println( st.nextToken() );
%>
</body>
</html> -
Is it possible to execute a ASP/CGI/PHP script thru sockets?
hi,
i was wondering whether it is possible in Java to pass data and execute ASP/CGI/PHP script on demand thru sockets (suppose a port has been specified by both sides) and how? i know this is possible thru the urlConnection, but how about sockets? these scripts could be stored in specific directories on the server.
thanks!!!hi,
i was wondering whether it is possible in Java to pass
data and execute ASP/CGI/PHP script on demand Yes, completely it's possible!
If you need to access ASP/CGI/PHP/Servlet/JSP thru' Java program, you can refer:
http://developer.java.sun.com/developer/qow/index.jsp
[after a week: http://developer.java.sun.com/developer/qow/archive/index.html
and look for 'Can I send an HTTP request to a servlet from a normal class without having to use a browser to send the HTTP requests?']
-and that's the QOW [Question Of the Week]!
thru sockets (suppose a port has been specified by both
sides) and how? When you say, a port has been specified on both sides,
then it becomes, a NET/Socket programming and you
need to use the 'net' package for the same.
i know this is possible thru the urlConnection, 'possible' means, it's assumed that u're invoking the 'script' thru' a web-server!
And u still use 'http://...' protocol to achieve the same; and u're NOT
directly accessing the script file as "file:\\network-host\root\files\abc.jsp"
but how about sockets? these scripts
could be stored in specific directories on the
server.It's not at all possible to 'invoke' those 'scripts' directly, by
using sockets; If you know that they're existing in one
particular directory of a network system, all you can do is
you can read the file content thru' socket, but you can't
make it become 'alive' and it would not dance for u!
Because, if there is a 'script' [PHP/ASP/CGI/JSP] that is
meant for dancing, then the stage for dancing is provided
by the web-server environment which starts the appropriate
server-side process that can understand and interpret the
given script! And all we can do is asking the web-server
to pull the 'script' to the stage and dance for you! But,
the 'asking' the webserver can be done thru' browser or
a URLConnection! If what you want to do would have been
possible, then, just with FTP we could have achieved the same!
Easy Go Jolly Java!
-RK -
Seeking JSR 223 Feedback -PHP/Java Integration-& giving feedback wrt JSC
This is also posted at
http://forum.java.sun.com/thread.jspa?threadID=691351
But I wanted to make sure this was given to the JSC folks.
I'm looking for feedback from anyone who has used jsr223. The last post on the jsr223 site was back in may 2005 from what I can tell and there is hardly any mention of it in the forums here.
While this may not be the correct forum, I didnt think this fell under JSF or JSTL directly.
I'm working at a small company with a number of php developers with a large code base in php, who I have been trying to convince to pick up another markup language like JSTL or JSF and were having a heck of a time getting Java Studio Creator to perform at anything near accceptable levels.
I'm very familiar with Struts, J2EE, and swing. While I have been trying to push JSF, thinking this would alleviate some of the complexity for php developers (at least this is what the Java Studio Creator hype claims, I'm having a hard time convincing them to do so when Java Studio Creator the supposed RAD JSF IDE is so slow. (running 1gb ram windoze xp professional)
I understand that the power in JSF is abstracting out request/response and having essentially interogated request objects with web apps for so long and then realizing the power of an event model to free me from the ever present controller switch statement to allow swing like callback
methods in webapps was well initially very refreshing and I was really hopeful.
However after trying to use studio creator....and Anyone who is using it and doesnt have this experience please let me know what we may be doing wrong (we are using JSC Early Access 2) and are experiencing compile and redeploy times that take 5-10 minutes or design time redraws in the ide that take 30 seconds to 2-3 minutes or longer.
This is simply not acceptable developer productivity for people who are application developers used to working with interpreted scripting langauges like php ( or for ms developers either for that matter).
So why dont We just use php then you say, well it doesnt scale well and there are so many apis that are available via java only. We also have a heck of a time with sockets in php and the java sockets api works really well/dependable/fast for us. And we realize how hard it is to enforce any sort of mvc pattern in a scripted language as well (although I know its possible with some php frameworks e.g. mojavi).
So We have turned to JSR 223 for my golden ticket - Java Scalability and Dependability with PHP like developer productivity.
I've got jsr223 samples working in tomcat 5.5 with php5. I can call a php page from inside of tomcat via the php servlet which allows you to access java objects and apis in that same php page that are on the tomcat web app classpath. ( Which I think is amazing quite frankly and the fact that this works at all I take my hat off to those who put it together, this maybe a great solution for us - and many others - considering our investments and need for developer productivity).
Our initial concept was to write the view tier in php, however I feel that this will quickly deteriorate to writing the controller in php as well, since they dont have to write servlet /struts mappings or faces config files.
And I think we may end up using only hibernate for persistence (the model) and axis for web services and Java for other heavy lifting tasks such as socket calls.
In any case I have not been able to find any real world feedback on this or any actual examples of anyone setting up a nontrivial JSR 223 architecture and the only thing I have is a few examples from the jsr site which are more like Proof Of Concept examples.
Anyone with any information please let me know. I have googled the heck out of jsr223 and jsr223 examples and am coming up emtpy handed and am worried that the last time the jsr223 site was updated was may 2005. I think this jsr may have been been put by the way side in the big push for JSF.
In any case if anyone at Sun sees this, if Java Studio Creator had anywhere near acceptable performance I probably wouldnt even be looking at JSR223
(I have even modified ant scripts to deploy directly to tomcat instead of the bundled Sun One App Server).
I dont want to get into a debate either with anyone about php over jsp or anything like that i just want to know is anyone actually using php with java via jsr223 and if so what does their architecture look like.
Trust me I would much rather not have to use php with java, but its pretty hard to convince a gang of time strapped php developers to use the tortoise like JSC and JSF when it takes a developer 4-5 times as long to develop a simple page with JSF in JSC as it would in php with a text editor.
Thanks in advance for any feedback,Winston, Thanks for the feedback
From http://blogs.sun.com/roller/page/tor?anchor=performance_tip_make_more_memory
To change the memory limit, do this: locate your IDE installation, and edit with a text editor.
In creator ea2 the file is at
C:\Program Files\Sun\Creator2ea2\etc\creator.conf
By default it is
-J-Xms96m -J-Xmx384m
I actually was using these settings
-J-Xms256m -J-Xmx512m
I changed this today to
-J-Xms256m -J-Xmx768m
I did see a noticeable improvement, still with some serious lags (note Im not running sunone on same machine, I'm deploying to tomcat on different box)
I monitored the ide's ram usage and it seemed to stabilized around just under 500mgs
I think that previous default settings will cause alot of garbage collection to go on since the ide seems to need more than the maximum amount of memory for the jvm and as a result this has got to be whats slowing the app down.
Have you altered the default memory settings, or are you using the default settings in C:\Program Files\Sun\Creator2ea2\etc\creator.conf.
I only have a gig of memory at my disposal at this time, I guess I will need to get some more, I imagine if you have 2gb of ram that you shoudlnt see any garbage collection if you arent using the default settings.
Thanks for your information about your setup.
Suggestion to the folks at JSC is to change these settings out of the box and up the minimum system requirements.
By the way Im still looking for anyone with feedback on jsr 223 (if there is a more appropriate forum please someone let me know).
R
S -
SMTP Email via JSP - is there no tag already?
I intend to send an email as part of a JSP page, but searches on the internet and within these forums have resulted in scriptlets or java application examples.
Is there not a simple tag that I can consider using instead? I do not want to mix code with my JSP and will probably write a custom JSP tag if I cant find one that has already been created - as part of JSTL / apache / someone reputable?
It's hard not to compare this to PHP whereby they have some sort of simple sendmail call - very straight forward if I recall.
Any help will be appreciated.
Regards,
Rob.[email protected] wrote:
Is there not a simple tag that I can consider using instead? I do not want to mix code with my JSP and will probably write a custom JSP tag if I cant find one that has already been created - as part of JSTL / apache / someone reputable?Just create a Servlet which makes use of the excellent JavaMail API and/or calls those Java applications. There is certainly no need to write Java code in JSP files.
Comparing PHP with JSP makes no sense. JSP is a web view technology for Java and PHP is a hypertext processor written in C.
Maybe you are looking for
-
SAP GUI taking too much time to open transactions
Hi guys, i have done system copy from Production to Quality server completely. after that i started SAP on Quality server, it is taking too much time for opening SAP transactions (it is going in compilation mode). i started SGEN, but it is giving tim
-
XML encoding to UTF-8 charset - Oracle 9i
Hi Masters Database Version : 9i Can you please help me here.. I am in a process of writing an Inventory Adjustment tool that will generate the XML and encode it to utf-8 charset… I have successfully written the code to generate the XML in this forma
-
How can I tune up WTK 2.5.2 performence except Preferences/Performance?
Hi Is there a way to tune up WTK 2.5.2 performence? I've already checked the Preferences/Performance. I'm developing J2ME application which uses a lot of icons etc. generaly it works ok. However when it comes to the screens with icons, the emulator i
-
Hello, Pls help me while I am intalling itunes for win7 I getting follwoing errro: an error occurred during the intallation of assembly Microsoft.VC80.CRT.type='win32".version="8.0.050727.6195",publicKeyToken="1fc8b .3b9a1e18e3b".processorArchitectyr
-
Need a way to automatically block HU stock when moved to damage bin.
I am looking for a way to automatically block stock when it is moved to certain bins. For example, when a handling unit is moved to a Damage bin (storage type 306), I would like movement type 344 to be executed to automatically hide the stock from A